diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2013-11-26 13:11:44 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2013-11-26 17:33:44 +0000 |
commit | 2d681ad020d3cd6beb53a0de1c3057537f31c8df (patch) | |
tree | 293ea2a7f2365e79dce3932b69e5900a81913496 /sax/source/fastparser | |
parent | 4932775dae4642bd1157495927c7fcda2589ca15 (diff) |
fastparser: don't waste cycles churning reference counts.
Diffstat (limited to 'sax/source/fastparser')
-rw-r--r-- | sax/source/fastparser/fastparser.cxx | 24 |
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) { |