Use boost::unordered_set for the String pool rather than my rather rubbish std::list. Much quicker. Patch provided by Gunther Laure

This commit is contained in:
Jez Higgins 2013-01-05 21:55:09 +00:00
parent 97ecf9040b
commit 2a9d8ca748

View file

@ -17,8 +17,8 @@
#include <DOM/Simple/NodeImpl.hpp> #include <DOM/Simple/NodeImpl.hpp>
#include <set> #include <set>
#include <list>
#include <algorithm> #include <algorithm>
#include <boost/unordered_set.hpp>
namespace Arabica namespace Arabica
{ {
@ -506,11 +506,7 @@ class DocumentImpl : public DOM::Document_impl<stringT, string_adaptorT>,
stringT const* stringPool(const stringT& str) const stringT const* stringPool(const stringT& str) const
{ {
typename std::list<stringT>::const_iterator i = std::find(stringPool_.begin(), stringPool_.end(), str); return &(*stringPool_.insert(str).first);
if(i != stringPool_.end())
return &(*i);
stringPool_.push_back(str);
return &(stringPool_.back());
} // stringPool } // stringPool
const stringT& empty_string() const { return empty_; } const stringT& empty_string() const { return empty_; }
@ -537,7 +533,7 @@ class DocumentImpl : public DOM::Document_impl<stringT, string_adaptorT>,
mutable std::set<NodeImplT*> orphans_; mutable std::set<NodeImplT*> orphans_;
std::set<AttrImplT*> idNodes_; std::set<AttrImplT*> idNodes_;
mutable std::list<stringT> stringPool_; mutable boost::unordered_set<stringT> stringPool_;
const stringT empty_; const stringT empty_;
}; // class DocumentImpl }; // class DocumentImpl