From 784d0f5d147b9a73f897ae55f6c3712d9a91b058 Mon Sep 17 00:00:00 2001 From: Manu Goyal Date: Wed, 29 Dec 2021 13:52:10 -0800 Subject: [PATCH] Use older vector constructor when allocating locks. It seems like the vector(count, allocator) constructor is not available until C++14. --- libcuckoo/cuckoohash_map.hh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libcuckoo/cuckoohash_map.hh b/libcuckoo/cuckoohash_map.hh index f919891..4cfd2ac 100644 --- a/libcuckoo/cuckoohash_map.hh +++ b/libcuckoo/cuckoohash_map.hh @@ -112,8 +112,8 @@ public: minimum_load_factor_(DEFAULT_MINIMUM_LOAD_FACTOR), maximum_hashpower_(NO_MAXIMUM_HASHPOWER), max_num_worker_threads_(0) { - all_locks_.emplace_back(std::min(bucket_count(), size_type(kMaxNumLocks)), - get_allocator()); + all_locks_.emplace_back(get_allocator()); + all_locks_.back().resize(std::min(bucket_count(), size_type(kMaxNumLocks))); } /** @@ -695,7 +695,8 @@ private: void add_locks_from_other(const cuckoohash_map &other) { locks_t &other_locks = other.get_current_locks(); - all_locks_.emplace_back(other_locks.size(), get_allocator()); + all_locks_.emplace_back(get_allocator()); + all_locks_.back().resize(other_locks.size()); std::copy(other_locks.begin(), other_locks.end(), get_current_locks().begin()); } @@ -1822,8 +1823,8 @@ private: return; } - locks_t new_locks(std::min(size_type(kMaxNumLocks), new_bucket_count), - get_allocator()); + locks_t new_locks(get_allocator()); + new_locks.resize(std::min(size_type(kMaxNumLocks), new_bucket_count)); assert(new_locks.size() > current_locks.size()); std::copy(current_locks.begin(), current_locks.end(), new_locks.begin()); for (spinlock &lock : new_locks) {