Revert "Optimize getNamespaceId (xmlreader)"

This reverts commit def0096124.

Finally after other tests, it doesn't improve perfs

Change-Id: Icbaaf751181069dd36dba0c676a4c9a2a6c8a9f3
Reviewed-on: https://gerrit.libreoffice.org/80565
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
This commit is contained in:
Julien Nabet 2019-10-09 20:30:42 +02:00
parent d55320b95b
commit 25a3658f51
4 changed files with 0 additions and 31 deletions

View file

@ -24,7 +24,6 @@
#include <cstddef>
#include <cstring>
#include <functional>
#include <sal/types.h>
#include <xmlreader/detail/xmlreaderdllapi.hxx>
@ -77,19 +76,6 @@ struct SAL_WARN_UNUSED OOO_DLLPUBLIC_XMLREADER Span {
}
rtl::OUString convertFromUtf8() const;
std::size_t hashCode() const;
};
}
namespace std {
template<>
struct hash<::xmlreader::Span>
{
std::size_t operator()(::xmlreader::Span const & s) const
{ return s.hashCode(); }
};
}

View file

@ -23,7 +23,6 @@
#include <sal/config.h>
#include <stack>
#include <unordered_map>
#include <vector>
#include <osl/file.h>
@ -173,7 +172,6 @@ private:
void * fileAddress_;
NamespaceIris namespaceIris_;
NamespaceList namespaces_;
mutable std::unordered_map<Span, int> cacheNSIds_;
ElementStack elements_;
char const * pos_;
char const * end_;

View file

@ -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: */

View file

@ -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;