From ed68caaaad263555b05da5d3f98136c41fabfe89 Mon Sep 17 00:00:00 2001 From: Daniel Burrows Date: Sat, 1 May 2010 08:50:53 -0700 Subject: Base the dynamic_list implementation off std::vector, not multi_index. The performance guarantees no longer let this be scalable, and it's only going to be used for short lists anyway, so scalability isn't that important. --- src/generic/util/dynamic_list_impl.h | 62 ++++++++---------------------------- src/gtk/toplevel/area.cc | 2 -- 2 files changed, 14 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/generic/util/dynamic_list_impl.h b/src/generic/util/dynamic_list_impl.h index ae405d87..2fde1336 100644 --- a/src/generic/util/dynamic_list_impl.h +++ b/src/generic/util/dynamic_list_impl.h @@ -21,13 +21,10 @@ #include #include -#include -#include -#include -#include -#include #include +#include + namespace aptitude { namespace util @@ -38,27 +35,7 @@ namespace aptitude : public writable_dynamic_list, public boost::enable_shared_from_this > { - // Uses multi_index_container to ensure that removals scale - // reasonably well. - - class hash_tag; - class list_tag; - typedef boost::multi_index::multi_index_container< - T, - boost::multi_index::indexed_by< - boost::multi_index::hashed_unique< - boost::multi_index::tag, - boost::multi_index::identity - >, - boost::multi_index::random_access< - boost::multi_index::tag - > - > - > collection; - - typedef typename collection::template index::type hash_index; - typedef typename collection::template index::type list_index; - + typedef std::vector collection; collection entries; public: @@ -87,43 +64,32 @@ namespace aptitude template boost::shared_ptr > dynamic_list_impl::enumerate() { - list_index &list = entries.template get(); + typedef iterator_enumerator_with_keepalive Tenum; - typedef iterator_enumerator_with_keepalive Tenum; - - return boost::make_shared(list.begin(), list.end(), + return boost::make_shared(entries.begin(), entries.end(), this->shared_from_this()); } template void dynamic_list_impl::append(const T &t) { - hash_index &hashed = entries.template get(); - if(hashed.find(t) == hashed.end()) - { - list_index &list = entries.template get(); - - list.push_back(t); - signal_appended(t); - } + entries.push_back(t); + signal_appended(t); } template void dynamic_list_impl::remove(const T &t) { - hash_index &hashed = entries.template get(); - typename hash_index::iterator found = hashed.find(t); + typename collection::iterator found = + std::find(entries.begin(), entries.end(), t); - if(found != hashed.end()) + if(found != entries.end()) { - const list_index &list = entries.template get(); - const typename list_index::const_iterator found_list = - entries.template project(found); - - const std::size_t idx = found_list - list.begin(); + const std::size_t idx = found - entries.begin(); - hashed.erase(found); - signal_removed(*found, idx); + T val = *found; + entries.erase(found); + signal_removed(val, idx); } } } diff --git a/src/gtk/toplevel/area.cc b/src/gtk/toplevel/area.cc index cd2b3b5b..19e82a1d 100644 --- a/src/gtk/toplevel/area.cc +++ b/src/gtk/toplevel/area.cc @@ -23,8 +23,6 @@ #include -using namespace boost::multi_index; - using aptitude::util::dynamic_list; using aptitude::util::dynamic_list_impl; using aptitude::util::enumerator; -- cgit v1.2.3