diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-05 12:33:51 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-08 11:48:05 +0200 |
commit | a2193f8f33565cc896592acb9d3ab65c756d97fb (patch) | |
tree | f5b8fe7cfe1710b452794dede14451ad5f9abe6e /include/sax/fastattribs.hxx | |
parent | 8164399df0df976784ddc1a76b46939c53ae51ee (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 'include/sax/fastattribs.hxx')
-rw-r--r-- | include/sax/fastattribs.hxx | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/sax/fastattribs.hxx b/include/sax/fastattribs.hxx index b5fbe225ee28..029f3a12f780 100644 --- a/include/sax/fastattribs.hxx +++ b/include/sax/fastattribs.hxx @@ -93,6 +93,9 @@ public: bool getAsInteger( sal_Int32 nToken, sal_Int32 &rInt) const; bool getAsDouble( sal_Int32 nToken, double &rDouble) const; bool getAsChar( sal_Int32 nToken, const char*& rPos ) const; + sal_Int32 getAsIntegerByIndex( sal_Int32 nTokenIndex ) const; + const char* getAsCharByIndex( sal_Int32 nTokenIndex ) const; + OUString getValueByIndex( sal_Int32 nTokenIndex ) const; // XFastAttributeList virtual sal_Bool SAL_CALL hasAttribute( ::sal_Int32 Token ) override; @@ -103,6 +106,14 @@ public: virtual css::uno::Sequence< css::xml::Attribute > SAL_CALL getUnknownAttributes( ) override; virtual css::uno::Sequence< css::xml::FastAttribute > SAL_CALL getFastAttributes() override; + sal_Int32 getAttributeIndex( ::sal_Int32 Token ) + { + for (size_t i=0; i<maAttributeTokens.size(); ++i) + if (maAttributeTokens[i] == Token) + return i; + return -1; + } + static FastAttributeList* castToFastAttributeList( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { |