|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r80384 - trunk/boost/unordered/detail
From: dnljms_at_[hidden]
Date: 2012-09-03 16:03:56
Author: danieljames
Date: 2012-09-03 16:03:55 EDT (Mon, 03 Sep 2012)
New Revision: 80384
URL: http://svn.boost.org/trac/boost/changeset/80384
Log:
Unordered: Avoid allocating nodes in table constructor.
Text files modified:
trunk/boost/unordered/detail/equivalent.hpp | 13 ++++++++++---
trunk/boost/unordered/detail/table.hpp | 26 +++++++++++++++++---------
trunk/boost/unordered/detail/unique.hpp | 13 ++++++++++---
3 files changed, 37 insertions(+), 15 deletions(-)
Modified: trunk/boost/unordered/detail/equivalent.hpp
==============================================================================
--- trunk/boost/unordered/detail/equivalent.hpp (original)
+++ trunk/boost/unordered/detail/equivalent.hpp 2012-09-03 16:03:55 EDT (Mon, 03 Sep 2012)
@@ -204,12 +204,17 @@
grouped_table_impl(grouped_table_impl const& x)
: table(x, node_allocator_traits::
- select_on_container_copy_construction(x.node_alloc())) {}
+ select_on_container_copy_construction(x.node_alloc()))
+ {
+ this->init(x);
+ }
grouped_table_impl(grouped_table_impl const& x,
node_allocator const& a)
: table(x, a)
- {}
+ {
+ this->init(x);
+ }
grouped_table_impl(grouped_table_impl& x,
boost::unordered::detail::move_tag m)
@@ -220,7 +225,9 @@
node_allocator const& a,
boost::unordered::detail::move_tag m)
: table(x, a, m)
- {}
+ {
+ this->move_init(x);
+ }
// Accessors
Modified: trunk/boost/unordered/detail/table.hpp
==============================================================================
--- trunk/boost/unordered/detail/table.hpp (original)
+++ trunk/boost/unordered/detail/table.hpp 2012-09-03 16:03:55 EDT (Mon, 03 Sep 2012)
@@ -235,14 +235,7 @@
functions(x),
mlf_(x.mlf_),
max_load_(0)
- {
- if(x.size_) {
- this->create_buckets(this->bucket_count_);
- copy_nodes<node_allocator> copy(this->node_alloc());
- table_impl::fill_buckets(x.get_start(), *this, copy);
- this->max_load_ = calculate_max_load();
- }
- }
+ {}
// TODO: Why calculate_max_load?
table(table& x, boost::unordered::detail::move_tag m) :
@@ -260,8 +253,23 @@
functions(x),
mlf_(x.mlf_),
max_load_(x.max_load_)
+ {}
+
+ // Initialisation.
+
+ void init(table const& x)
+ {
+ if (x.size_) {
+ this->create_buckets(this->bucket_count_);
+ copy_nodes<node_allocator> copy(this->node_alloc());
+ table_impl::fill_buckets(x.get_start(), *this, copy);
+ this->max_load_ = calculate_max_load();
+ }
+ }
+
+ void move_init(table& x)
{
- if(a == x.node_alloc()) {
+ if(this->node_alloc() == x.node_alloc()) {
this->move_buckets_from(x);
}
else if(x.size_) {
Modified: trunk/boost/unordered/detail/unique.hpp
==============================================================================
--- trunk/boost/unordered/detail/unique.hpp (original)
+++ trunk/boost/unordered/detail/unique.hpp 2012-09-03 16:03:55 EDT (Mon, 03 Sep 2012)
@@ -202,12 +202,17 @@
table_impl(table_impl const& x)
: table(x, node_allocator_traits::
- select_on_container_copy_construction(x.node_alloc())) {}
+ select_on_container_copy_construction(x.node_alloc()))
+ {
+ this->init(x);
+ }
table_impl(table_impl const& x,
node_allocator const& a)
: table(x, a)
- {}
+ {
+ this->init(x);
+ }
table_impl(table_impl& x,
boost::unordered::detail::move_tag m)
@@ -218,7 +223,9 @@
node_allocator const& a,
boost::unordered::detail::move_tag m)
: table(x, a, m)
- {}
+ {
+ this->move_init(x);
+ }
// Accessors
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk