summaryrefslogtreecommitdiff
path: root/sax
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2013-12-31 12:59:03 +0000
committerMichael Meeks <michael.meeks@collabora.com>2014-01-02 10:55:44 +0000
commitd683df6c22a2e6be4d5db644e30832b3fe3e64af (patch)
treed953772cde134781467b6bfb4dd120f9e38d61fc /sax
parent4df7072a88691fb11916dc23f5bd0f35cb6227e6 (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.cxx22
1 files changed, 9 insertions, 13 deletions
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index 88bef41c6d9c..c123401e7b72 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -231,8 +231,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 );
@@ -263,6 +263,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;
};
@@ -631,7 +633,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 ) );
}
@@ -1078,21 +1082,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 !