summaryrefslogtreecommitdiff
path: root/writerfilter
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 /writerfilter
parent2d681ad020d3cd6beb53a0de1c3057537f31c8df (diff)
fastparser: Avoid copying all tokens into a sequence.
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/ooxml/OOXMLFastTokenHandler.cxx23
-rw-r--r--writerfilter/source/ooxml/OOXMLFastTokenHandler.hxx7
2 files changed, 18 insertions, 12 deletions
diff --git a/writerfilter/source/ooxml/OOXMLFastTokenHandler.cxx b/writerfilter/source/ooxml/OOXMLFastTokenHandler.cxx
index 096de7f0b9c1..4cf32f562a27 100644
--- a/writerfilter/source/ooxml/OOXMLFastTokenHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastTokenHandler.cxx
@@ -108,23 +108,16 @@ css::uno::Sequence< ::sal_Int8 > SAL_CALL OOXMLFastTokenHandler::getUTF8Identifi
#endif
}
-::sal_Int32 SAL_CALL OOXMLFastTokenHandler::getTokenFromUTF8
-(const css::uno::Sequence< ::sal_Int8 > & Identifier) throw (css::uno::RuntimeException)
+::sal_Int32 SAL_CALL OOXMLFastTokenHandler::getTokenDirect( const char *pStr, sal_Int32 nLength ) const
{
- ::sal_Int32 nResult = OOXML_FAST_TOKENS_END;
-
struct tokenmap::token * pToken =
- tokenmap::Perfect_Hash::in_word_set
- (reinterpret_cast<const char *>(Identifier.getConstArray()),
- Identifier.getLength());
+ tokenmap::Perfect_Hash::in_word_set( pStr, nLength );
- if (pToken != NULL)
- nResult = pToken->nToken;
+ sal_Int32 nResult = pToken != NULL ? pToken->nToken : OOXML_FAST_TOKENS_END;
#ifdef DEBUG_TOKEN
clog << "getTokenFromUTF8: "
- << string(reinterpret_cast<const char *>
- (Identifier.getConstArray()), Identifier.getLength())
+ << string(pStr, nLength)
<< ", " << nResult
<< (pToken == NULL ? ", failed" : "") << endl;
#endif
@@ -132,6 +125,14 @@ css::uno::Sequence< ::sal_Int8 > SAL_CALL OOXMLFastTokenHandler::getUTF8Identifi
return nResult;
}
+::sal_Int32 SAL_CALL OOXMLFastTokenHandler::getTokenFromUTF8
+(const css::uno::Sequence< ::sal_Int8 > & Identifier) throw (css::uno::RuntimeException)
+{
+ return getTokenDirect(reinterpret_cast<const char *>
+ (Identifier.getConstArray()),
+ Identifier.getLength());
+}
+
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/ooxml/OOXMLFastTokenHandler.hxx b/writerfilter/source/ooxml/OOXMLFastTokenHandler.hxx
index 120c4e70a74f..ddb5b50d153a 100644
--- a/writerfilter/source/ooxml/OOXMLFastTokenHandler.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastTokenHandler.hxx
@@ -24,6 +24,7 @@
#include "com/sun/star/uno/XComponentContext.hpp"
#include "cppuhelper/implbase1.hxx"
#include "com/sun/star/xml/sax/XFastTokenHandler.hpp"
+#include "sax/fastattribs.hxx"
namespace writerfilter {
namespace ooxml
@@ -31,7 +32,8 @@ namespace ooxml
class OOXMLFastTokenHandler:
public ::cppu::WeakImplHelper1<
- css::xml::sax::XFastTokenHandler>
+ css::xml::sax::XFastTokenHandler>,
+ public sax_fastparser::FastTokenHandlerBase
{
public:
explicit OOXMLFastTokenHandler(css::uno::Reference< css::uno::XComponentContext > const & context);
@@ -42,6 +44,9 @@ public:
virtual css::uno::Sequence< ::sal_Int8 > SAL_CALL getUTF8Identifier(::sal_Int32 Token) throw (css::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getTokenFromUTF8(const css::uno::Sequence< ::sal_Int8 > & Identifier) throw (css::uno::RuntimeException);
+ // Much faster direct C++ shortcut to the method that matters
+ virtual sal_Int32 getTokenDirect( const char *pToken, sal_Int32 nLength ) const;
+
private:
OOXMLFastTokenHandler(OOXMLFastTokenHandler &); // not defined
void operator =(OOXMLFastTokenHandler &); // not defined