summaryrefslogtreecommitdiff
path: root/include/oox/token
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 /include/oox/token
parent2d681ad020d3cd6beb53a0de1c3057537f31c8df (diff)
fastparser: Avoid copying all tokens into a sequence.
Diffstat (limited to 'include/oox/token')
-rw-r--r--include/oox/token/tokenmap.hxx22
1 files changed, 21 insertions, 1 deletions
diff --git a/include/oox/token/tokenmap.hxx b/include/oox/token/tokenmap.hxx
index 495fa2d6eb3e..bddc0ce6a34d 100644
--- a/include/oox/token/tokenmap.hxx
+++ b/include/oox/token/tokenmap.hxx
@@ -47,9 +47,29 @@ public:
/** Returns the token identifier for the passed UTF8 token name. */
sal_Int32 getTokenFromUtf8(
- const ::com::sun::star::uno::Sequence< sal_Int8 >& rUtf8Name ) const;
+ const ::com::sun::star::uno::Sequence< sal_Int8 >& rUtf8Name ) const
+ {
+ return getTokenFromUTF8( reinterpret_cast< const char * >(
+ rUtf8Name.getConstArray() ),
+ rUtf8Name.getLength() );
+ }
+
+ /** Returns the token identifier for a UTF8 string passed in pToken */
+ sal_Int32 getTokenFromUTF8( const char *pToken, sal_Int32 nLength ) const
+ {
+ // 50% of OOXML tokens are primarily 1 lower-case character, a-z
+ if( nLength == 1)
+ {
+ sal_Char c = pToken[0];
+ if (c >= 'a' && c <= 'z')
+ return mnAlphaTokens[ c - 'a' ];
+ }
+ return getTokenPerfectHash( pToken, nLength );
+ }
private:
+ sal_Int32 getTokenPerfectHash( const char *pToken, sal_Int32 nLength ) const;
+
struct TokenName
{
OUString maUniName;