summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2013-11-26 16:26:12 +0000
committerMichael Meeks <michael.meeks@collabora.com>2013-11-26 17:33:44 +0000
commitd7280af9740819971f46a855108334b84778b47d (patch)
tree12f13fe1c9afcaa2b2e4ab3a7d22a70bda710c23 /oox
parent2d681ad020d3cd6beb53a0de1c3057537f31c8df (diff)
fastparser: Avoid copying all tokens into a sequence.
Diffstat (limited to 'oox')
-rw-r--r--oox/source/core/fasttokenhandler.cxx5
-rw-r--r--oox/source/token/tokenmap.cxx12
2 files changed, 7 insertions, 10 deletions
diff --git a/oox/source/core/fasttokenhandler.cxx b/oox/source/core/fasttokenhandler.cxx
index f57739c92d1c..510240863845 100644
--- a/oox/source/core/fasttokenhandler.cxx
+++ b/oox/source/core/fasttokenhandler.cxx
@@ -92,6 +92,11 @@ sal_Int32 FastTokenHandler::getTokenFromUTF8( const Sequence< sal_Int8 >& rIdent
return mrTokenMap.getTokenFromUtf8( rIdentifier );
}
+sal_Int32 FastTokenHandler::getTokenDirect( const char *pToken, sal_Int32 nLength ) const
+{
+ return mrTokenMap.getTokenFromUTF8( pToken, nLength );
+}
+
// ============================================================================
} // namespace core
diff --git a/oox/source/token/tokenmap.cxx b/oox/source/token/tokenmap.cxx
index ea3e621e3792..7728b26bff06 100644
--- a/oox/source/token/tokenmap.cxx
+++ b/oox/source/token/tokenmap.cxx
@@ -113,17 +113,9 @@ Sequence< sal_Int8 > TokenMap::getUtf8TokenName( sal_Int32 nToken ) const
return Sequence< sal_Int8 >();
}
-sal_Int32 TokenMap::getTokenFromUtf8( const Sequence< sal_Int8 >& rUtf8Name ) const
+sal_Int32 TokenMap::getTokenPerfectHash( const char *pStr, sal_Int32 nLength ) const
{
- // 50% of OOXML tokens are primarily 1 lower-case character, a-z
- if( rUtf8Name.getLength() == 1)
- {
- sal_Char c = rUtf8Name[0];
- if (c >= 'a' && c <= 'z')
- return mnAlphaTokens[ c - 'a' ];
- }
- struct xmltoken* pToken = Perfect_Hash::in_word_set(
- reinterpret_cast< const char* >( rUtf8Name.getConstArray() ), rUtf8Name.getLength() );
+ struct xmltoken* pToken = Perfect_Hash::in_word_set( pStr, nLength );
return pToken ? pToken->nToken : XML_TOKEN_INVALID;
}