[Libreoffice-commits] core.git: Branch 'feature/chart-opengl2' - sax/source
Michael Meeks
michael.meeks at collabora.com
Tue Dec 31 05:00:31 PST 2013
sax/source/fastparser/fastparser.cxx | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
New commits:
commit 17e74f2989ad20b1149084205fbfcbedb06a2bd0
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Tue Dec 31 12:59:03 2013 +0000
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
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index a7ba27b..cc9ad2f 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 !
More information about the Libreoffice-commits
mailing list