forked from boostorg/unordered
fixed space reservation in concurrent_table::operator=(std::initializer_list)
This commit is contained in:
@ -414,9 +414,7 @@ public:
|
||||
concurrent_table& operator=(std::initializer_list<value_type> il) {
|
||||
auto lck=exclusive_access();
|
||||
super::clear();
|
||||
if (super::capacity()<il.size()) {
|
||||
super::reserve(il.size());
|
||||
}
|
||||
super::noshrink_reserve(il.size());
|
||||
for (auto const& v : il) {
|
||||
this->unprotected_emplace(v);
|
||||
}
|
||||
|
@ -1642,6 +1642,24 @@ public:
|
||||
return it;
|
||||
}
|
||||
|
||||
void noshrink_reserve(std::size_t n)
|
||||
{
|
||||
/* used only on assignment after element clearance */
|
||||
BOOST_ASSERT(empty());
|
||||
|
||||
if(n){
|
||||
n=std::size_t(std::ceil(float(n)/mlf)); /* elements -> slots */
|
||||
n=capacity_for(n); /* exact resulting capacity */
|
||||
|
||||
if(n>capacity()){
|
||||
auto new_arrays_=new_arrays(n);
|
||||
delete_arrays(arrays);
|
||||
arrays=new_arrays_;
|
||||
ml=initial_max_load();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
void for_all_elements(F f)const
|
||||
{
|
||||
@ -1947,24 +1965,6 @@ private:
|
||||
ml=initial_max_load();
|
||||
}
|
||||
|
||||
void noshrink_reserve(std::size_t n)
|
||||
{
|
||||
/* used only on assignment after element clearance */
|
||||
BOOST_ASSERT(empty());
|
||||
|
||||
if(n){
|
||||
n=std::size_t(std::ceil(float(n)/mlf)); /* elements -> slots */
|
||||
n=capacity_for(n); /* exact resulting capacity */
|
||||
|
||||
if(n>capacity()){
|
||||
auto new_arrays_=new_arrays(n);
|
||||
delete_arrays(arrays);
|
||||
arrays=new_arrays_;
|
||||
ml=initial_max_load();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
void unchecked_insert(Value&& x)
|
||||
{
|
||||
|
Reference in New Issue
Block a user