From 25a3658f514e644ca89294530f1cd5398795dcfb Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Wed, 9 Oct 2019 20:30:42 +0200 Subject: Revert "Optimize getNamespaceId (xmlreader)" This reverts commit def00961243da0662f394bdf58b1157cfd45dfab. Finally after other tests, it doesn't improve perfs Change-Id: Icbaaf751181069dd36dba0c676a4c9a2a6c8a9f3 Reviewed-on: https://gerrit.libreoffice.org/80565 Reviewed-by: Julien Nabet Tested-by: Julien Nabet --- xmlreader/source/span.cxx | 4 ---- xmlreader/source/xmlreader.cxx | 11 ----------- 2 files changed, 15 deletions(-) (limited to 'xmlreader') diff --git a/xmlreader/source/span.cxx b/xmlreader/source/span.cxx index 300c0a2e99b3..29433c561fb7 100644 --- a/xmlreader/source/span.cxx +++ b/xmlreader/source/span.cxx @@ -46,10 +46,6 @@ OUString Span::convertFromUtf8() const { return OUString(s, SAL_NO_ACQUIRE); } -std::size_t Span::hashCode() const { - return rtl_str_hashCode_WithLength(begin, length); -} - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmlreader/source/xmlreader.cxx b/xmlreader/source/xmlreader.cxx index 918f42a2e1b2..85027b66ee99 100644 --- a/xmlreader/source/xmlreader.cxx +++ b/xmlreader/source/xmlreader.cxx @@ -182,19 +182,11 @@ Span XmlReader::getAttributeValue(bool fullyNormalize) { } int XmlReader::getNamespaceId(Span const & prefix) const { - if (auto it = cacheNSIds_.find(prefix); it != cacheNSIds_.end()) - { - return it->second; - } - auto i = std::find_if(namespaces_.crbegin(), namespaces_.crend(), [&prefix](const NamespaceData& rNamespaceData) { return prefix == rNamespaceData.prefix; }); if (i != namespaces_.rend()) - { - cacheNSIds_[i->prefix]= i->nsId; return i->nsId; - } return NAMESPACE_UNKNOWN; } @@ -714,10 +706,7 @@ XmlReader::Result XmlReader::handleEndTag() { void XmlReader::handleElementEnd() { assert(!elements_.empty()); - // remove keys from cache that are no longer valid auto end = elements_.top().inheritedNamespaces; - for (auto i = end; i < namespaces_.size(); ++i) - cacheNSIds_.erase(namespaces_[i].prefix); namespaces_.resize(end); elements_.pop(); state_ = elements_.empty() ? State::Done : State::Content; -- cgit