forked from boostorg/unordered
refactored size_/ml swap
This commit is contained in:
@@ -1226,6 +1226,7 @@ public:
|
|||||||
using alloc_traits=boost::allocator_traits<Allocator>;
|
using alloc_traits=boost::allocator_traits<Allocator>;
|
||||||
using element_type=typename type_policy::element_type;
|
using element_type=typename type_policy::element_type;
|
||||||
using arrays_type=Arrays<element_type,group_type,size_policy>;
|
using arrays_type=Arrays<element_type,group_type,size_policy>;
|
||||||
|
using size_impl_type=SizeImpl;
|
||||||
|
|
||||||
using key_type=typename type_policy::key_type;
|
using key_type=typename type_policy::key_type;
|
||||||
using init_type=typename type_policy::init_type;
|
using init_type=typename type_policy::init_type;
|
||||||
@@ -1281,20 +1282,8 @@ public:
|
|||||||
{
|
{
|
||||||
if(al()==x.al()){
|
if(al()==x.al()){
|
||||||
std::swap(arrays,x.arrays);
|
std::swap(arrays,x.arrays);
|
||||||
|
swap_size_impl(size_,x.size_);
|
||||||
// when SizeImpl is an atomic<Integral> type, std::swap() can't be used
|
swap_size_impl(ml,x.ml);
|
||||||
// as it's not MoveConstructible so we instead opt for this manual version
|
|
||||||
{
|
|
||||||
std::size_t tmp{size_};
|
|
||||||
size_=static_cast<std::size_t>(x.size_);
|
|
||||||
x.size_=tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
std::size_t tmp{ml};
|
|
||||||
ml=static_cast<std::size_t>(x.ml);
|
|
||||||
x.ml=tmp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
reserve(x.size());
|
reserve(x.size());
|
||||||
@@ -1708,9 +1697,9 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
arrays_type arrays;
|
arrays_type arrays;
|
||||||
SizeImpl ml;
|
size_impl_type ml;
|
||||||
SizeImpl size_;
|
size_impl_type size_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<
|
template<
|
||||||
@@ -1875,6 +1864,14 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void swap_size_impl(size_impl_type& x,size_impl_type& y)
|
||||||
|
{
|
||||||
|
/* std::swap can't be used on non-assignable atomics */
|
||||||
|
std::size_t tmp=x;
|
||||||
|
x=static_cast<std::size_t>(y);
|
||||||
|
y=tmp;
|
||||||
|
}
|
||||||
|
|
||||||
void recover_slot(unsigned char* pc)
|
void recover_slot(unsigned char* pc)
|
||||||
{
|
{
|
||||||
/* If this slot potentially caused overflow, we decrease the maximum load so
|
/* If this slot potentially caused overflow, we decrease the maximum load so
|
||||||
|
Reference in New Issue
Block a user