Unordered: Avoid unnecessary swapping in rehash and move.

[SVN r80378]
This commit is contained in:
Daniel James
2012-09-03 20:01:50 +00:00
parent c0faf59a86
commit 7a4930f1a1
4 changed files with 44 additions and 52 deletions

View File

@@ -626,7 +626,7 @@ namespace boost { namespace unordered { namespace detail {
{
BOOST_ASSERT(!dst.buckets_);
dst.create_buckets();
dst.create_buckets(dst.bucket_count_);
node_constructor a(dst.node_alloc());
@@ -657,7 +657,7 @@ namespace boost { namespace unordered { namespace detail {
{
BOOST_ASSERT(!dst.buckets_);
dst.create_buckets();
dst.create_buckets(dst.bucket_count_);
node_constructor a(dst.node_alloc());
@@ -683,24 +683,10 @@ namespace boost { namespace unordered { namespace detail {
{
BOOST_ASSERT(this->size_);
buckets dst(this->node_alloc(), num_buckets);
dst.create_buckets();
previous_pointer src_start = this->get_previous_start();
previous_pointer dst_start = dst.get_previous_start();
dst_start->next_ = src_start->next_;
src_start->next_ = link_pointer();
dst.size_ = this->size_;
this->size_ = 0;
previous_pointer prev = dst.get_previous_start();
this->create_buckets(num_buckets);
previous_pointer prev = this->get_previous_start();
while (prev->next_)
prev = place_in_bucket(dst, prev);
// Swap the new nodes back into the container and setup the
// variables.
dst.swap(*this); // no throw
prev = place_in_bucket(*this, prev);
}
// Iterate through the nodes placing them in the correct buckets.