diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2013-12-31 12:59:03 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2013-12-31 14:06:21 +0000 |
commit | 4754b8ac5074d86234cafe1b1401f6d22f14b929 (patch) | |
tree | 39a8dd71720b7724ee20cedaa6880fbc03dde66d /sax | |
parent | 38f23632c854145fe6e4853624864d533912ab21 (diff) |
fastparser: avoid std::stack::top() - cache it's results.
amazingly std::stack::top() takes 146 pseudo-cycles to do not much,
so instead cache the result in a single pointer in lieu of burning
that code.
Change-Id: Ie326be47da6cbad0850e5f1026a1632bb840b6b8
Diffstat (limited to 'sax')
-rw-r--r-- | sax/source/fastparser/fastparser.cxx | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx index f2f90c48bb18..96993f8589c1 100644 --- a/sax/source/fastparser/fastparser.cxx +++ b/sax/source/fastparser/fastparser.cxx @@ -224,8 +224,8 @@ public: void pushEntity( const Entity& rEntity ); void popEntity(); - Entity& getEntity(); - const Entity& getEntity() const; + Entity& getEntity() { return *mpTop; } + const Entity& getEntity() const { return *mpTop; } void parse(); void produce( CallbackType aType ); @@ -256,6 +256,8 @@ private: NamespaceMap maNamespaceMap; ParserData maData; /// Cached parser configuration for next call of parseStream(). + + Entity *mpTop; /// std::stack::top() is amazingly slow => cache this. ::std::stack< Entity > maEntities; /// Entity stack for each call of parseStream(). FastTokenLookup maTokenLookup; }; @@ -619,7 +621,9 @@ void Entity::saveException( const Exception &e ) namespace sax_fastparser { -FastSaxParserImpl::FastSaxParserImpl( FastSaxParser* pFront ) : mpFront(pFront) +FastSaxParserImpl::FastSaxParserImpl( FastSaxParser* pFront ) : + mpFront(pFront), + mpTop(NULL) { mxDocumentLocator.set( new FastLocatorImpl( this ) ); } @@ -1038,21 +1042,13 @@ bool FastSaxParserImpl::consume(EventList *pEventList) void FastSaxParserImpl::pushEntity( const Entity& rEntity ) { maEntities.push( rEntity ); + mpTop = &maEntities.top(); } void FastSaxParserImpl::popEntity() { maEntities.pop(); -} - -Entity& FastSaxParserImpl::getEntity() -{ - return maEntities.top(); -} - -const Entity& FastSaxParserImpl::getEntity() const -{ - return maEntities.top(); + mpTop = &maEntities.top(); } // starts parsing with actual parser ! |