forked from boostorg/unordered
Unordered: Avoid allocating nodes in table constructor.
[SVN r80384]
This commit is contained in:
@ -204,12 +204,17 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
grouped_table_impl(grouped_table_impl const& x)
|
grouped_table_impl(grouped_table_impl const& x)
|
||||||
: table(x, node_allocator_traits::
|
: 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,
|
grouped_table_impl(grouped_table_impl const& x,
|
||||||
node_allocator const& a)
|
node_allocator const& a)
|
||||||
: table(x, a)
|
: table(x, a)
|
||||||
{}
|
{
|
||||||
|
this->init(x);
|
||||||
|
}
|
||||||
|
|
||||||
grouped_table_impl(grouped_table_impl& x,
|
grouped_table_impl(grouped_table_impl& x,
|
||||||
boost::unordered::detail::move_tag m)
|
boost::unordered::detail::move_tag m)
|
||||||
@ -220,7 +225,9 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
node_allocator const& a,
|
node_allocator const& a,
|
||||||
boost::unordered::detail::move_tag m)
|
boost::unordered::detail::move_tag m)
|
||||||
: table(x, a, m)
|
: table(x, a, m)
|
||||||
{}
|
{
|
||||||
|
this->move_init(x);
|
||||||
|
}
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
|
|
||||||
|
@ -235,14 +235,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
functions(x),
|
functions(x),
|
||||||
mlf_(x.mlf_),
|
mlf_(x.mlf_),
|
||||||
max_load_(0)
|
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?
|
// TODO: Why calculate_max_load?
|
||||||
table(table& x, boost::unordered::detail::move_tag m) :
|
table(table& x, boost::unordered::detail::move_tag m) :
|
||||||
@ -260,8 +253,23 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
functions(x),
|
functions(x),
|
||||||
mlf_(x.mlf_),
|
mlf_(x.mlf_),
|
||||||
max_load_(x.max_load_)
|
max_load_(x.max_load_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
// Initialisation.
|
||||||
|
|
||||||
|
void init(table const& x)
|
||||||
{
|
{
|
||||||
if(a == x.node_alloc()) {
|
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(this->node_alloc() == x.node_alloc()) {
|
||||||
this->move_buckets_from(x);
|
this->move_buckets_from(x);
|
||||||
}
|
}
|
||||||
else if(x.size_) {
|
else if(x.size_) {
|
||||||
|
@ -202,12 +202,17 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
|
|
||||||
table_impl(table_impl const& x)
|
table_impl(table_impl const& x)
|
||||||
: table(x, node_allocator_traits::
|
: 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,
|
table_impl(table_impl const& x,
|
||||||
node_allocator const& a)
|
node_allocator const& a)
|
||||||
: table(x, a)
|
: table(x, a)
|
||||||
{}
|
{
|
||||||
|
this->init(x);
|
||||||
|
}
|
||||||
|
|
||||||
table_impl(table_impl& x,
|
table_impl(table_impl& x,
|
||||||
boost::unordered::detail::move_tag m)
|
boost::unordered::detail::move_tag m)
|
||||||
@ -218,7 +223,9 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
node_allocator const& a,
|
node_allocator const& a,
|
||||||
boost::unordered::detail::move_tag m)
|
boost::unordered::detail::move_tag m)
|
||||||
: table(x, a, m)
|
: table(x, a, m)
|
||||||
{}
|
{
|
||||||
|
this->move_init(x);
|
||||||
|
}
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user