summaryrefslogtreecommitdiff
path: root/sax/source/fastparser
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-07-05 12:33:51 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-07-08 11:48:05 +0200
commita2193f8f33565cc896592acb9d3ab65c756d97fb (patch)
treef5b8fe7cfe1710b452794dede14451ad5f9abe6e /sax/source/fastparser
parent8164399df0df976784ddc1a76b46939c53ae51ee (diff)
tdf#79878 perf loading docx file, sax improvements
these are the smaller improvements, they make about 5% worth of difference - use std::vector instead of std::deque - use std::move on pendingCharacters instead of copying - in FastAttributeList::add, when reallocate the buffer, allocate twice the existing size, instead of increasing to only what we need - in FastAttributeList, create getAttributeIndex and friends, so we can avoid iterating the attribute list more often than necessary Change-Id: I3e3380ea50b77c6845b66e83404e245778ec06eb Reviewed-on: https://gerrit.libreoffice.org/57021 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sax/source/fastparser')
-rw-r--r--sax/source/fastparser/fastparser.cxx13
1 files changed, 7 insertions, 6 deletions
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index 2765584a08fc..9477559c12e8 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -178,13 +178,13 @@ struct Entity : public ParserData
void throwException( const ::rtl::Reference< FastLocatorImpl > &xDocumentLocator,
bool mbDuringParse );
- std::stack< NameWithToken > maNamespaceStack;
+ std::stack< NameWithToken, std::vector<NameWithToken> > maNamespaceStack;
/* Context for main thread consuming events.
* startElement() stores the data, which characters() and endElement() uses
*/
- std::stack< SaxContext> maContextStack;
+ std::stack< SaxContext, std::vector<SaxContext> > maContextStack;
// Determines which elements of maNamespaceDefines are valid in current context
- std::stack< sal_uInt32 > maNamespaceCount;
+ std::stack< sal_uInt32, std::vector<sal_uInt32> > maNamespaceCount;
std::vector< std::shared_ptr< NamespaceDefine > >
maNamespaceDefines;
@@ -270,7 +270,7 @@ private:
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().
+ std::stack< Entity > maEntities; /// Entity stack for each call of parseStream().
OUString pendingCharacters; /// Data from characters() callback that needs to be sent.
};
@@ -674,11 +674,12 @@ sal_Int32 FastSaxParserImpl::GetTokenWithPrefix( const xmlChar* pPrefix, int nPr
sal_uInt32 nNamespace = rEntity.maNamespaceCount.top();
while( nNamespace-- )
{
- const OString& rPrefix( rEntity.maNamespaceDefines[nNamespace]->maPrefix );
+ const auto & rNamespaceDefine = rEntity.maNamespaceDefines[nNamespace];
+ const OString& rPrefix( rNamespaceDefine->maPrefix );
if( (rPrefix.getLength() == nPrefixLen) &&
(strncmp( rPrefix.getStr(), XML_CAST( pPrefix ), nPrefixLen ) == 0 ) )
{
- nNamespaceToken = rEntity.maNamespaceDefines[nNamespace]->mnToken;
+ nNamespaceToken = rNamespaceDefine->mnToken;
break;
}