[libc++] Don't call key_eq in unordered_map/set rehashing routine

As of now containers key_eq might get called when rehashing happens, which is redundant for unique keys containers.

Reviewed By: #libc, philnik, Mordante

Differential Revision: https://reviews.llvm.org/D128021
This commit is contained in:
Ivan Trofimov 2022-07-10 11:41:02 +02:00 committed by Mark de Wever
parent 393e12bddd
commit 3085e42f80
7 changed files with 143 additions and 81 deletions

View File

@ -135,6 +135,20 @@ static void BM_FindRehash(benchmark::State& st, Container c, GenInputs gen) {
}
}
template <class Container, class GenInputs>
static void BM_Rehash(benchmark::State& st, Container c, GenInputs gen) {
auto in = gen(st.range(0));
c.max_load_factor(3.0);
c.insert(in.begin(), in.end());
benchmark::DoNotOptimize(c);
const auto bucket_count = c.bucket_count();
while (st.KeepRunning()) {
c.rehash(bucket_count + 1);
c.rehash(bucket_count);
benchmark::ClobberMemory();
}
}
} // end namespace ContainerBenchmarks
#endif // BENCHMARK_CONTAINER_BENCHMARKS_H

View File

@ -104,6 +104,27 @@ struct UInt64Hash2 {
}
};
// The sole purpose of this comparator is to be used in BM_Rehash, where
// we need something slow enough to be easily noticable in benchmark results.
// The default implementation of operator== for strings seems to be a little
// too fast for that specific benchmark to reliably show a noticeable
// improvement, but unoptimized bytewise comparison fits just right.
// Early return is there just for convenience, since we only compare strings
// of equal length in BM_Rehash.
struct SlowStringEq {
SlowStringEq() = default;
inline TEST_ALWAYS_INLINE
bool operator()(const std::string& lhs, const std::string& rhs) const {
if (lhs.size() != rhs.size()) return false;
bool eq = true;
for (size_t i = 0; i < lhs.size(); ++i) {
eq &= lhs[i] == rhs[i];
}
return eq;
}
};
//----------------------------------------------------------------------------//
// BM_Hash
// ---------------------------------------------------------------------------//
@ -266,6 +287,20 @@ BENCHMARK_CAPTURE(BM_FindRehash,
std::unordered_set<std::string>{},
getRandomStringInputs)->Arg(TestNumInputs);
//----------------------------------------------------------------------------//
// BM_Rehash
// ---------------------------------------------------------------------------//
BENCHMARK_CAPTURE(BM_Rehash,
unordered_set_string_arg,
std::unordered_set<std::string, std::hash<std::string>, SlowStringEq>{},
getRandomStringInputs)->Arg(TestNumInputs);
BENCHMARK_CAPTURE(BM_Rehash,
unordered_set_int_arg,
std::unordered_set<int>{},
getRandomIntegerInputs<int>)->Arg(TestNumInputs);
///////////////////////////////////////////////////////////////////////////////
BENCHMARK_CAPTURE(BM_InsertDuplicate,
unordered_set_int,

View File

@ -1146,9 +1146,16 @@ public:
#endif
void clear() _NOEXCEPT;
void rehash(size_type __n);
_LIBCPP_INLINE_VISIBILITY void reserve(size_type __n)
{rehash(static_cast<size_type>(ceil(__n / max_load_factor())));}
_LIBCPP_INLINE_VISIBILITY void __rehash_unique(size_type __n) { __rehash<true>(__n); }
_LIBCPP_INLINE_VISIBILITY void __rehash_multi(size_type __n) { __rehash<false>(__n); }
_LIBCPP_INLINE_VISIBILITY void __reserve_unique(size_type __n)
{
__rehash_unique(static_cast<size_type>(ceil(__n / max_load_factor())));
}
_LIBCPP_INLINE_VISIBILITY void __reserve_multi(size_type __n)
{
__rehash_multi(static_cast<size_type>(ceil(__n / max_load_factor())));
}
_LIBCPP_INLINE_VISIBILITY
size_type bucket_count() const _NOEXCEPT
@ -1285,7 +1292,8 @@ public:
#endif // _LIBCPP_ENABLE_DEBUG_MODE
private:
void __rehash(size_type __n);
template <bool _UniqueKeys> void __rehash(size_type __n);
template <bool _UniqueKeys> void __do_rehash(size_type __n);
template <class ..._Args>
__node_holder __construct_node(_Args&& ...__args);
@ -1790,7 +1798,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(
}
if (size()+1 > __bc * max_load_factor() || __bc == 0)
{
rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
__rehash_unique(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
size_type(ceil(float(size() + 1) / max_load_factor()))));
}
return nullptr;
@ -1862,7 +1870,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(
size_type __bc = bucket_count();
if (size()+1 > __bc * max_load_factor() || __bc == 0)
{
rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
__rehash_multi(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
size_type(ceil(float(size() + 1) / max_load_factor()))));
__bc = bucket_count();
}
@ -1956,7 +1964,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(
size_type __bc = bucket_count();
if (size()+1 > __bc * max_load_factor() || __bc == 0)
{
rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
__rehash_multi(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
size_type(ceil(float(size() + 1) / max_load_factor()))));
__bc = bucket_count();
}
@ -2004,7 +2012,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const&
__node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...);
if (size()+1 > __bc * max_load_factor() || __bc == 0)
{
rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
__rehash_unique(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc),
size_type(ceil(float(size() + 1) / max_load_factor()))));
__bc = bucket_count();
__chash = __constrain_hash(__hash, __bc);
@ -2207,8 +2215,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_multi(
#endif // _LIBCPP_STD_VER > 14
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <bool _UniqueKeys>
void
__hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __n)
_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
{
if (__n == 1)
@ -2217,7 +2226,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
__n = __next_prime(__n);
size_type __bc = bucket_count();
if (__n > __bc)
__rehash(__n);
__do_rehash<_UniqueKeys>(__n);
else if (__n < __bc)
{
__n = _VSTD::max<size_type>
@ -2227,13 +2236,14 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
__next_prime(size_t(ceil(float(size()) / max_load_factor())))
);
if (__n < __bc)
__rehash(__n);
__do_rehash<_UniqueKeys>(__n);
}
}
template <class _Tp, class _Hash, class _Equal, class _Alloc>
template <bool _UniqueKeys>
void
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc)
__hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc)
{
std::__debug_db_invalidate_all(this);
__pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc();
@ -2268,11 +2278,14 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc)
else
{
__next_pointer __np = __cp;
for (; __np->__next_ != nullptr &&
key_eq()(__cp->__upcast()->__value_,
__np->__next_->__upcast()->__value_);
__np = __np->__next_)
;
if _LIBCPP_CONSTEXPR_AFTER_CXX14 (!_UniqueKeys)
{
for (; __np->__next_ != nullptr &&
key_eq()(__cp->__upcast()->__value_,
__np->__next_->__upcast()->__value_);
__np = __np->__next_)
;
}
__pp->__next_ = __np->__next_;
__np->__next_ = __bucket_list_[__chash]->__next_;
__bucket_list_[__chash]->__next_ = __cp;

View File

@ -605,7 +605,7 @@ public:
{return __table_.bucket_size(__n);}
_LIBCPP_INLINE_VISIBILITY
void resize(size_type __n) {__table_.rehash(__n);}
void resize(size_type __n) {__table_.__rehash_unique(__n);}
private:
__node_holder __construct_node(const key_type& __k);
@ -616,7 +616,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
size_type __n, const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
__table_.__rehash_unique(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@ -625,7 +625,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
__table_.__rehash_unique(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@ -643,7 +643,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
__table_.__rehash_unique(__n);
insert(__first, __last);
}
@ -654,7 +654,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
__table_.__rehash_unique(__n);
insert(__first, __last);
}
@ -663,7 +663,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
const hash_map& __u)
: __table_(__u.__table_)
{
__table_.rehash(__u.bucket_count());
__table_.__rehash_unique(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@ -874,7 +874,7 @@ public:
{return __table_.bucket_size(__n);}
_LIBCPP_INLINE_VISIBILITY
void resize(size_type __n) {__table_.rehash(__n);}
void resize(size_type __n) {__table_.__rehash_multi(__n);}
};
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@ -882,7 +882,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
size_type __n, const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
__table_.__rehash_multi(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@ -891,7 +891,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
__table_.__rehash_multi(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@ -909,7 +909,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
__table_.__rehash_multi(__n);
insert(__first, __last);
}
@ -920,7 +920,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
__table_.__rehash_multi(__n);
insert(__first, __last);
}
@ -929,7 +929,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
const hash_multimap& __u)
: __table_(__u.__table_)
{
__table_.rehash(__u.bucket_count());
__table_.__rehash_multi(__u.bucket_count());
insert(__u.begin(), __u.end());
}

View File

@ -333,7 +333,7 @@ public:
size_type elems_in_bucket(size_type __n) const {return __table_.bucket_size(__n);}
_LIBCPP_INLINE_VISIBILITY
void resize(size_type __n) {__table_.rehash(__n);}
void resize(size_type __n) {__table_.__rehash_unique(__n);}
};
template <class _Value, class _Hash, class _Pred, class _Alloc>
@ -341,7 +341,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(size_type __n,
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
__table_.__rehash_unique(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@ -349,7 +349,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(size_type __n,
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
__table_.__rehash_unique(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@ -367,7 +367,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
__table_.__rehash_unique(__n);
insert(__first, __last);
}
@ -378,7 +378,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
__table_.__rehash_unique(__n);
insert(__first, __last);
}
@ -387,7 +387,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
const hash_set& __u)
: __table_(__u.__table_)
{
__table_.rehash(__u.bucket_count());
__table_.__rehash_unique(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@ -553,7 +553,7 @@ public:
size_type elems_in_bucket(size_type __n) const {return __table_.bucket_size(__n);}
_LIBCPP_INLINE_VISIBILITY
void resize(size_type __n) {__table_.rehash(__n);}
void resize(size_type __n) {__table_.__rehash_multi(__n);}
};
template <class _Value, class _Hash, class _Pred, class _Alloc>
@ -561,7 +561,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
size_type __n, const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
__table_.__rehash_multi(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@ -570,7 +570,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
__table_.__rehash_multi(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@ -588,7 +588,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
__table_.__rehash_multi(__n);
insert(__first, __last);
}
@ -599,7 +599,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
__table_.__rehash_multi(__n);
insert(__first, __last);
}
@ -608,7 +608,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
const hash_multiset& __u)
: __table_(__u.__table_)
{
__table_.rehash(__u.bucket_count());
__table_.__rehash_multi(__u.bucket_count());
insert(__u.begin(), __u.end());
}

View File

@ -1525,9 +1525,9 @@ public:
_LIBCPP_INLINE_VISIBILITY
void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
_LIBCPP_INLINE_VISIBILITY
void rehash(size_type __n) {__table_.rehash(__n);}
void rehash(size_type __n) {__table_.__rehash_unique(__n);}
_LIBCPP_INLINE_VISIBILITY
void reserve(size_type __n) {__table_.reserve(__n);}
void reserve(size_type __n) {__table_.__reserve_unique(__n);}
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
@ -1626,7 +1626,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_unique(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@ -1636,7 +1636,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_unique(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@ -1665,7 +1665,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_unique(__n);
insert(__first, __last);
}
@ -1677,7 +1677,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_unique(__n);
insert(__first, __last);
}
@ -1687,7 +1687,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
: __table_(__u.__table_)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__u.bucket_count());
__table_.__rehash_unique(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@ -1697,7 +1697,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
: __table_(__u.__table_, typename __table::allocator_type(__a))
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__u.bucket_count());
__table_.__rehash_unique(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@ -1747,7 +1747,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_unique(__n);
insert(__il.begin(), __il.end());
}
@ -1758,7 +1758,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_unique(__n);
insert(__il.begin(), __il.end());
}
@ -2301,9 +2301,9 @@ public:
_LIBCPP_INLINE_VISIBILITY
void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
_LIBCPP_INLINE_VISIBILITY
void rehash(size_type __n) {__table_.rehash(__n);}
void rehash(size_type __n) {__table_.__rehash_multi(__n);}
_LIBCPP_INLINE_VISIBILITY
void reserve(size_type __n) {__table_.reserve(__n);}
void reserve(size_type __n) {__table_.__reserve_multi(__n);}
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
@ -2398,7 +2398,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_multi(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@ -2408,7 +2408,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_multi(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
@ -2428,7 +2428,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_multi(__n);
insert(__first, __last);
}
@ -2440,7 +2440,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_multi(__n);
insert(__first, __last);
}
@ -2459,7 +2459,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
: __table_(__u.__table_)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__u.bucket_count());
__table_.__rehash_multi(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@ -2469,7 +2469,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
: __table_(__u.__table_, typename __table::allocator_type(__a))
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__u.bucket_count());
__table_.__rehash_multi(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@ -2520,7 +2520,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_multi(__n);
insert(__il.begin(), __il.end());
}
@ -2531,7 +2531,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
: __table_(__hf, __eql, typename __table::allocator_type(__a))
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_multi(__n);
insert(__il.begin(), __il.end());
}

View File

@ -858,9 +858,9 @@ public:
_LIBCPP_INLINE_VISIBILITY
void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
_LIBCPP_INLINE_VISIBILITY
void rehash(size_type __n) {__table_.rehash(__n);}
void rehash(size_type __n) {__table_.__rehash_unique(__n);}
_LIBCPP_INLINE_VISIBILITY
void reserve(size_type __n) {__table_.reserve(__n);}
void reserve(size_type __n) {__table_.__reserve_unique(__n);}
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
@ -942,7 +942,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_unique(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@ -951,7 +951,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
: __table_(__hf, __eql, __a)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_unique(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@ -971,7 +971,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_unique(__n);
insert(__first, __last);
}
@ -983,7 +983,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
: __table_(__hf, __eql, __a)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_unique(__n);
insert(__first, __last);
}
@ -1002,7 +1002,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
: __table_(__u.__table_)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__u.bucket_count());
__table_.__rehash_unique(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@ -1012,7 +1012,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
: __table_(__u.__table_, __a)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__u.bucket_count());
__table_.__rehash_unique(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@ -1060,7 +1060,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_unique(__n);
insert(__il.begin(), __il.end());
}
@ -1071,7 +1071,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
: __table_(__hf, __eql, __a)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_unique(__n);
insert(__il.begin(), __il.end());
}
@ -1496,9 +1496,9 @@ public:
_LIBCPP_INLINE_VISIBILITY
void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
_LIBCPP_INLINE_VISIBILITY
void rehash(size_type __n) {__table_.rehash(__n);}
void rehash(size_type __n) {__table_.__rehash_multi(__n);}
_LIBCPP_INLINE_VISIBILITY
void reserve(size_type __n) {__table_.reserve(__n);}
void reserve(size_type __n) {__table_.__reserve_multi(__n);}
#ifdef _LIBCPP_ENABLE_DEBUG_MODE
@ -1578,7 +1578,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_multi(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@ -1588,7 +1588,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
: __table_(__hf, __eql, __a)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_multi(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
@ -1608,7 +1608,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_multi(__n);
insert(__first, __last);
}
@ -1620,7 +1620,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
: __table_(__hf, __eql, __a)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_multi(__n);
insert(__first, __last);
}
@ -1639,7 +1639,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
: __table_(__u.__table_)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__u.bucket_count());
__table_.__rehash_multi(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@ -1649,7 +1649,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
: __table_(__u.__table_, __a)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__u.bucket_count());
__table_.__rehash_multi(__u.bucket_count());
insert(__u.begin(), __u.end());
}
@ -1697,7 +1697,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
: __table_(__hf, __eql)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_multi(__n);
insert(__il.begin(), __il.end());
}
@ -1708,7 +1708,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
: __table_(__hf, __eql, __a)
{
_VSTD::__debug_db_insert_c(this);
__table_.rehash(__n);
__table_.__rehash_multi(__n);
insert(__il.begin(), __il.end());
}