From 22e6daac6c00cde0b3a6a159d7304fea05f302c7 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 3 Sep 2012 20:03:35 +0000 Subject: [PATCH] Unordered: Use node_holder for move. [SVN r80383] --- include/boost/unordered/detail/buckets.hpp | 7 +++++++ include/boost/unordered/detail/table.hpp | 11 ++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/boost/unordered/detail/buckets.hpp b/include/boost/unordered/detail/buckets.hpp index c4c18cfe..a72b9568 100644 --- a/include/boost/unordered/detail/buckets.hpp +++ b/include/boost/unordered/detail/buckets.hpp @@ -443,6 +443,8 @@ namespace boost { namespace unordered { namespace detail { typedef typename node_allocator_traits::pointer node_pointer; typedef typename node::value_type value_type; typedef typename node::link_pointer link_pointer; + typedef boost::unordered::iterator_detail:: + iterator iterator; node_pointer nodes_; @@ -514,6 +516,11 @@ namespace boost { namespace unordered { namespace detail { return base::release(); } } + + iterator get_start() const + { + return iterator(nodes_); + } }; template diff --git a/include/boost/unordered/detail/table.hpp b/include/boost/unordered/detail/table.hpp index 19663f48..24035a8a 100644 --- a/include/boost/unordered/detail/table.hpp +++ b/include/boost/unordered/detail/table.hpp @@ -255,7 +255,7 @@ namespace boost { namespace unordered { namespace detail { // TODO: Why not calculate_max_load? // TODO: Why do I use x's bucket count? table(table& x, node_allocator const& a, - boost::unordered::detail::move_tag m) : + boost::unordered::detail::move_tag) : buckets(a, x.bucket_count_), functions(x), mlf_(x.mlf_), @@ -265,14 +265,11 @@ namespace boost { namespace unordered { namespace detail { this->move_buckets_from(x); } else if(x.size_) { - // Use a temporary table because moving the nodes leaves the - // source container in a complete mess. - - buckets tmp(x, m); - this->create_buckets(this->bucket_count_); + move_nodes move(this->node_alloc()); - table_impl::fill_buckets(tmp.get_start(), *this, move); + node_holder nodes(x); + table_impl::fill_buckets(nodes.get_start(), *this, move); this->max_load_ = calculate_max_load(); }