diff options
author | Robin Gareus <robin@gareus.org> | 2016-04-08 21:03:23 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-04-08 21:03:23 +0200 |
commit | 3def1b2830528319d2b720267e2f153dd17d72c0 (patch) | |
tree | 9d595ad5f857d6bc8cd088af0bb038063efcaf8d /libs | |
parent | d1dcedaccfd5adfd661724476003410d5d251756 (diff) |
more potential session-save speedup.
std:vector trumps std::list speed in all aspects: traversal, insertion
(at end) and Deletion. ..but we'll have to be careful about iterators..
Diffstat (limited to 'libs')
-rw-r--r-- | libs/pbd/pbd/xml++.h | 16 | ||||
-rw-r--r-- | libs/pbd/xml++.cc | 32 |
2 files changed, 21 insertions, 27 deletions
diff --git a/libs/pbd/pbd/xml++.h b/libs/pbd/pbd/xml++.h index 7b8649873a..dac8de67cd 100644 --- a/libs/pbd/pbd/xml++.h +++ b/libs/pbd/pbd/xml++.h @@ -28,7 +28,7 @@ */ #include <string> -#include <list> +#include <vector> #include <unordered_map> #include <cstdio> #include <cstdarg> @@ -43,13 +43,13 @@ class XMLTree; class XMLNode; class XMLProperty; -typedef std::list<XMLNode *> XMLNodeList; -typedef std::list<boost::shared_ptr<XMLNode> > XMLSharedNodeList; -typedef XMLNodeList::iterator XMLNodeIterator; -typedef XMLNodeList::const_iterator XMLNodeConstIterator; -typedef std::list<XMLProperty*> XMLPropertyList; -typedef XMLPropertyList::iterator XMLPropertyIterator; -typedef XMLPropertyList::const_iterator XMLPropertyConstIterator; +typedef std::vector<XMLNode *> XMLNodeList; +typedef std::vector<boost::shared_ptr<XMLNode> > XMLSharedNodeList; +typedef XMLNodeList::iterator XMLNodeIterator; +typedef XMLNodeList::const_iterator XMLNodeConstIterator; +typedef std::vector<XMLProperty*> XMLPropertyList; +typedef XMLPropertyList::iterator XMLPropertyIterator; +typedef XMLPropertyList::const_iterator XMLPropertyConstIterator; typedef std::unordered_map<std::string, XMLProperty*> XMLPropertyMap; class LIBPBD_API XMLTree { diff --git a/libs/pbd/xml++.cc b/libs/pbd/xml++.cc index cc583fe86e..b8fff12ad0 100644 --- a/libs/pbd/xml++.cc +++ b/libs/pbd/xml++.cc @@ -472,7 +472,10 @@ XMLNode::remove_property(const string& n) { if (_propmap.find(n) != _propmap.end()) { XMLProperty* p = _propmap[n]; - _proplist.remove (p); + XMLPropertyIterator i = std::find(_proplist.begin(), _proplist.end(), p); + if (i != _proplist.end ()) { + _proplist.erase (i); + } delete p; _propmap.erase(n); } @@ -492,15 +495,12 @@ void XMLNode::remove_nodes(const string& n) { XMLNodeIterator i = _children.begin(); - XMLNodeIterator tmp; - while (i != _children.end()) { - tmp = i; - ++tmp; if ((*i)->name() == n) { - _children.erase (i); + i = _children.erase (i); + } else { + ++i; } - i = tmp; } } @@ -508,16 +508,14 @@ void XMLNode::remove_nodes_and_delete(const string& n) { XMLNodeIterator i = _children.begin(); - XMLNodeIterator tmp; while (i != _children.end()) { - tmp = i; - ++tmp; if ((*i)->name() == n) { delete *i; - _children.erase (i); + i = _children.erase (i); + } else { + ++i; } - i = tmp; } } @@ -525,20 +523,16 @@ void XMLNode::remove_nodes_and_delete(const string& propname, const string& val) { XMLNodeIterator i = _children.begin(); - XMLNodeIterator tmp; XMLProperty* prop; while (i != _children.end()) { - tmp = i; - ++tmp; - prop = (*i)->property(propname); if (prop && prop->value() == val) { delete *i; - _children.erase(i); + i = _children.erase(i); + } else { + ++i; } - - i = tmp; } } |