summaryrefslogtreecommitdiff
path: root/sax
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2013-11-26 13:11:44 +0000
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-12-04 11:41:33 -0500
commit0e652adef5bda6438d1b9084397fc5c43e5dd21a (patch)
tree29c7c2c0809533ceeb95a4fad1bdbf1d555bae66 /sax
parenta8c7e6355542e5afee5975a093f5d5e0bc418e39 (diff)
fastparser: don't waste cycles churning reference counts.
Diffstat (limited to 'sax')
-rw-r--r--sax/source/fastparser/fastparser.cxx24
1 files changed, 13 insertions, 11 deletions
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index da224d0a62fe..415747c63614 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -227,18 +227,20 @@ void Entity::startElement( Event *pEvent )
const sal_Int32& nElementToken = pEvent->mnElementToken;
const OUString& aNamespace = pEvent->msNamespace;
const OUString& aElementName = pEvent->msElementName;
- Reference< XFastContextHandler > xParentContext;
+
+ // Use un-wrapped pointers to avoid significant acquire/release overhead
+ XFastContextHandler *pParentContext = NULL;
if( !maContextStack.empty() )
{
- xParentContext = maContextStack.top().mxContext;
- if (!xParentContext.is())
+ pParentContext = maContextStack.top().mxContext.get();
+ if( !pParentContext )
{
maContextStack.push( SaxContext(nElementToken, aNamespace, aElementName) );
return;
}
}
- maContextStack.push( SaxContext(nElementToken, aNamespace, aElementName) );
+ maContextStack.push( SaxContext( nElementToken, aNamespace, aElementName ) );
try
{
@@ -246,8 +248,8 @@ void Entity::startElement( Event *pEvent )
Reference< XFastContextHandler > xContext;
if( nElementToken == FastToken::DONTKNOW )
{
- if( xParentContext.is() )
- xContext = xParentContext->createUnknownChildContext( aNamespace, aElementName, xAttr );
+ if( pParentContext )
+ xContext = pParentContext->createUnknownChildContext( aNamespace, aElementName, xAttr );
else if( mxDocumentHandler.is() )
xContext = mxDocumentHandler->createUnknownChildContext( aNamespace, aElementName, xAttr );
@@ -258,17 +260,17 @@ void Entity::startElement( Event *pEvent )
}
else
{
- if( xParentContext.is() )
- xContext = xParentContext->createFastChildContext( nElementToken, xAttr );
+ if( pParentContext )
+ xContext = pParentContext->createFastChildContext( nElementToken, xAttr );
else if( mxDocumentHandler.is() )
xContext = mxDocumentHandler->createFastChildContext( nElementToken, xAttr );
if( xContext.is() )
- {
xContext->startFastElement( nElementToken, xAttr );
- }
}
- maContextStack.top().mxContext = xContext;
+ // swap the reference we own in to avoid referencing thrash.
+ maContextStack.top().mxContext.set( static_cast<XFastContextHandler *>( xContext.get() ) );
+ xContext.set( NULL, UNO_REF_NO_ACQUIRE );
}
catch (const Exception& e)
{