Skip to content

Commit

Permalink
Use older vector constructor when allocating locks.
Browse files Browse the repository at this point in the history
It seems like the vector(count, allocator) constructor is not available until
C++14.
  • Loading branch information
manugoyal committed Dec 29, 2021
1 parent 2362469 commit 784d0f5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions libcuckoo/cuckoohash_map.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}

/**
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 784d0f5

Please sign in to comment.