diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-09-12 14:34:26 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-09-12 23:09:23 +0200 |
commit | 3a37d8320c0b8a7bced8e67f7ed2581d4013e38b (patch) | |
tree | 17ca2d40fa7adf23d732694db49aaad9d7ff6918 /sax/qa | |
parent | 128b19c33088dcd3dab55074a70a545e4b47a190 (diff) |
Optimize TokenMap and AttributeList in oox and xo
Shaves lots of string allocations, and uses optimized code paths
Change-Id: I8e33e2aecdc7e0d2f2c31b774daa36304b3973ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173179
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sax/qa')
-rw-r--r-- | sax/qa/cppunit/parser.cxx | 2 | ||||
-rw-r--r-- | sax/qa/cppunit/xmlimport.cxx | 9 |
2 files changed, 5 insertions, 6 deletions
diff --git a/sax/qa/cppunit/parser.cxx b/sax/qa/cppunit/parser.cxx index 670c1afa9277..288a91eefda0 100644 --- a/sax/qa/cppunit/parser.cxx +++ b/sax/qa/cppunit/parser.cxx @@ -37,7 +37,7 @@ public: CPPUNIT_ASSERT_MESSAGE( "getUTF8Identifier: unexpected call", false ); return uno::Sequence<sal_Int8>(); } - virtual sal_Int32 getTokenDirect( const char * /* pToken */, sal_Int32 /* nLength */ ) const override + virtual sal_Int32 getTokenDirect(std::string_view /* token */) const override { return -1; } diff --git a/sax/qa/cppunit/xmlimport.cxx b/sax/qa/cppunit/xmlimport.cxx index 963fa97f6893..18f8c9a21112 100644 --- a/sax/qa/cppunit/xmlimport.cxx +++ b/sax/qa/cppunit/xmlimport.cxx @@ -262,7 +262,7 @@ public: virtual Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 nToken ) override; virtual sal_Int32 SAL_CALL getTokenFromUTF8( const css::uno::Sequence< sal_Int8 >& Identifier ) override; //FastTokenHandlerBase - virtual sal_Int32 getTokenDirect( const char *pToken, sal_Int32 nLength ) const override; + virtual sal_Int32 getTokenDirect(std::string_view sToken) const override; }; const std::string_view DummyTokenHandler::tokens[] = { @@ -304,13 +304,12 @@ Sequence< sal_Int8 > DummyTokenHandler::getUTF8Identifier( sal_Int32 nToken ) sal_Int32 DummyTokenHandler::getTokenFromUTF8( const uno::Sequence< sal_Int8 >& rIdentifier ) { - return getTokenDirect( reinterpret_cast< const char* >( - rIdentifier.getConstArray() ), rIdentifier.getLength() ); + return getTokenDirect(std::string_view( + reinterpret_cast<const char*>(rIdentifier.getConstArray()), rIdentifier.getLength())); } -sal_Int32 DummyTokenHandler::getTokenDirect( const char* pToken, sal_Int32 nLength ) const +sal_Int32 DummyTokenHandler::getTokenDirect(std::string_view sToken) const { - std::string_view sToken( pToken, nLength ); for( size_t i = 0; i < std::size(tokens); i++ ) { if ( tokens[i] == sToken ) |