summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2013-11-26 16:26:12 +0000
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-12-04 11:41:33 -0500
commit16a38eb854d2303e9a723651c3ab66897efe03d0 (patch)
treeca8a2bba7a688a5765a3648b69cf82154e5dbb3f /oox
parent0e652adef5bda6438d1b9084397fc5c43e5dd21a (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;
}