summaryrefslogtreecommitdiff
path: root/include/xmloff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-10-31 14:06:21 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-10-31 18:54:45 +0100
commit885ae558d34dd76955c727b90eb9ae52ce85df7f (patch)
tree3dfe7a3f9ba268b3ec1affff1795dc23018fe260 /include/xmloff
parent09758c0e717a9ff31b004532906f902763300a93 (diff)
tdf#125688, cache token names as OUString
to avoid construction cost, shaves 2% off load time Change-Id: I37a70a6e989f53d67911a6cb217d07e2db55cb44 Reviewed-on: https://gerrit.libreoffice.org/81841 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/xmloff')
-rw-r--r--include/xmloff/fasttokenhandler.hxx16
-rw-r--r--include/xmloff/xmlimp.hxx7
2 files changed, 19 insertions, 4 deletions
diff --git a/include/xmloff/fasttokenhandler.hxx b/include/xmloff/fasttokenhandler.hxx
index a95b3506a5f1..e134604eae70 100644
--- a/include/xmloff/fasttokenhandler.hxx
+++ b/include/xmloff/fasttokenhandler.hxx
@@ -32,10 +32,18 @@ public:
{
SAL_WARN_IF(nToken < 0 || nToken >= XML_TOKEN_COUNT, "xmloff", "Wrong nToken parameter");
if( 0 <= nToken && nToken < XML_TOKEN_COUNT )
- return maTokenNames[ nToken ];
+ return maTokenNamesUtf8[ nToken ];
return EMPTY_BYTE_SEQ;
}
+ const OUString& getTokenName( sal_Int32 nToken ) const
+ {
+ SAL_WARN_IF(nToken < 0 || nToken >= XML_TOKEN_COUNT, "xmloff", "Wrong nToken parameter");
+ if( 0 <= nToken && nToken < XML_TOKEN_COUNT )
+ return maTokenNames[ nToken ];
+ return EMPTY_STRING;
+ }
+
/** Returns the token identifier for the passed UTF-8 token name. */
static sal_Int32 getTokenFromUtf8( const css::uno::Sequence< sal_Int8 >& rUtf8Name )
{
@@ -52,9 +60,11 @@ public:
private:
static sal_Int32 getTokenPerfectHash( const char *pToken, sal_Int32 nLength );
- std::vector< css::uno::Sequence< sal_Int8 > > maTokenNames;
+ std::vector< css::uno::Sequence< sal_Int8 > > maTokenNamesUtf8;
+ std::vector< OUString > maTokenNames;
static const css::uno::Sequence< sal_Int8 > EMPTY_BYTE_SEQ;
+ static const OUString EMPTY_STRING;
};
struct StaticTokenMap : public rtl::Static< TokenMap, StaticTokenMap > {};
@@ -71,6 +81,8 @@ public:
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 nToken ) override;
virtual sal_Int32 SAL_CALL getTokenFromUTF8( const css::uno::Sequence< sal_Int8 >& Identifier ) override;
+ const OUString & getIdentifier( sal_Int32 nToken ) const;
+
// Much faster direct C++ shortcut to the method that matters
virtual sal_Int32 getTokenDirect( const char *pToken, sal_Int32 nLength ) const override;
diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx
index 78bc26a7c234..0007f6dd5086 100644
--- a/include/xmloff/xmlimp.hxx
+++ b/include/xmloff/xmlimp.hxx
@@ -90,6 +90,9 @@ enum class SvXMLErrorFlags;
namespace xmloff {
class RDFaImportHelper;
}
+namespace xmloff::token {
+ class FastTokenHandler;
+}
enum class SvXMLImportFlags {
NONE = 0x0000,
@@ -219,7 +222,7 @@ class XMLOFF_DLLPUBLIC SvXMLImport : public cppu::WeakImplHelper<
rtl::Reference < comphelper::AttributeList > maAttrList;
rtl::Reference < comphelper::AttributeList > maNamespaceAttrList;
css::uno::Reference< css::xml::sax::XFastDocumentHandler > mxFastDocumentHandler;
- static css::uno::Reference< css::xml::sax::XFastTokenHandler > xTokenHandler;
+ static rtl::Reference< xmloff::token::FastTokenHandler > xTokenHandler;
static std::unordered_map< sal_Int32, std::pair< OUString, OUString > > aNamespaceMap;
static std::unordered_map< OUString, OUString > aNamespaceURIPrefixMap;
static bool bIsNSMapsInitialized;
@@ -377,7 +380,7 @@ public:
// get import helper for events
XMLEventImportHelper& GetEventImport();
- static OUString getNameFromToken( sal_Int32 nToken );
+ static const OUString & getNameFromToken( sal_Int32 nToken );
static OUString getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap* pMap);
static OUString getNamespaceURIFromToken( sal_Int32 nToken );
static OUString getNamespacePrefixFromURI( const OUString& rURI );