diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-03-11 14:19:34 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-25 12:13:26 +0200 |
commit | 0dbc76a3ca25f43232073484541504e342380d0a (patch) | |
tree | d0324098ee97a845cbbf9f7205a43af94ca7306d /sax/source/tools | |
parent | af9642350db024e9a9ff73f46693ff5d0a4ce66b (diff) |
make FastParser always take a FastTokenHandlerBase subclass
since most of the call sites already do, and we can skip the
slow path this way.
Change-Id: I64ed30c51324e0510818f42ef838f97c401bb6dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90326
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sax/source/tools')
-rw-r--r-- | sax/source/tools/fastattribs.cxx | 20 | ||||
-rw-r--r-- | sax/source/tools/fshelper.cxx | 2 |
2 files changed, 6 insertions, 16 deletions
diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx index 587749938c6b..3df391c86150 100644 --- a/sax/source/tools/fastattribs.cxx +++ b/sax/source/tools/fastattribs.cxx @@ -54,10 +54,8 @@ void UnknownAttribute::FillAttribute( Attribute* pAttrib ) const } } -FastAttributeList::FastAttributeList( const css::uno::Reference< css::xml::sax::XFastTokenHandler >& xTokenHandler, - sax_fastparser::FastTokenHandlerBase *pTokenHandler) -: mxTokenHandler( xTokenHandler ), - mpTokenHandler( pTokenHandler ) +FastAttributeList::FastAttributeList( sax_fastparser::FastTokenHandlerBase *pTokenHandler) +: mpTokenHandler( pTokenHandler ) { // random initial size of buffer to store attribute values mnChunkLength = 58; @@ -140,7 +138,7 @@ sal_Int32 FastAttributeList::getValueToken( ::sal_Int32 Token ) for (size_t i = 0; i < maAttributeTokens.size(); ++i) if (maAttributeTokens[i] == Token) return FastTokenHandlerBase::getTokenFromChars( - mxTokenHandler, mpTokenHandler, + mpTokenHandler, getFastAttributeValue(i), AttributeValueLength( i ) ); @@ -152,7 +150,7 @@ sal_Int32 FastAttributeList::getOptionalValueToken( ::sal_Int32 Token, ::sal_Int for (size_t i = 0; i < maAttributeTokens.size(); ++i) if (maAttributeTokens[i] == Token) return FastTokenHandlerBase::getTokenFromChars( - mxTokenHandler, mpTokenHandler, + mpTokenHandler, getFastAttributeValue(i), AttributeValueLength( i ) ); @@ -265,7 +263,6 @@ FastAttributeList::FastAttributeIter FastAttributeList::find( sal_Int32 nToken ) } sal_Int32 FastTokenHandlerBase::getTokenFromChars( - const css::uno::Reference< css::xml::sax::XFastTokenHandler > &xTokenHandler, const FastTokenHandlerBase *pTokenHandler, const char *pToken, size_t nLen /* = 0 */ ) { @@ -274,14 +271,7 @@ sal_Int32 FastTokenHandlerBase::getTokenFromChars( if( !nLen ) nLen = strlen( pToken ); - if( pTokenHandler ) - nRet = pTokenHandler->getTokenDirect( pToken, static_cast<sal_Int32>(nLen) ); - else - { - // heap allocate, copy & then free - Sequence< sal_Int8 > aSeq( reinterpret_cast<sal_Int8 const *>(pToken), nLen ); - nRet = xTokenHandler->getTokenFromUTF8( aSeq ); - } + nRet = pTokenHandler->getTokenDirect( pToken, static_cast<sal_Int32>(nLen) ); return nRet; } diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx index 0d265fe36d24..41857c95ef19 100644 --- a/sax/source/tools/fshelper.cxx +++ b/sax/source/tools/fshelper.cxx @@ -149,7 +149,7 @@ void FastSerializerHelper::mergeTopMarks( FastAttributeList * FastSerializerHelper::createAttrList() { - return new FastAttributeList( Reference< xml::sax::XFastTokenHandler >() ); + return new FastAttributeList( nullptr ); } |