From 1db53ba155f3bf2e7bf7eaf6f439a2b52abf170b Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Wed, 15 Dec 2021 09:42:44 -0800 Subject: [PATCH] Update internal table to allocate on construction and when rehashing --- include/boost/unordered/detail/implementation.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index b65d4bc0..8661e408 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -2486,6 +2486,7 @@ namespace boost { bucket_count_(policy::new_bucket_count(num_buckets)), size_(0), mlf_(1.0f), max_load_(0), buckets_() { + this->create_buckets(bucket_count_); } table(table const& x, node_allocator const& a) @@ -3951,8 +3952,10 @@ namespace boost { using namespace std; if (!size_) { - delete_buckets(); - bucket_count_ = policy::new_bucket_count(min_buckets); + min_buckets = policy::new_bucket_count(min_buckets); + if (min_buckets != bucket_count_) { + this->create_buckets(min_buckets); + } } else { min_buckets = policy::new_bucket_count((std::max)(min_buckets, boost::unordered::detail::double_to_size(