Commit 8da5b759 authored by Dan Melnic's avatar Dan Melnic Committed by Facebook GitHub Bot

folly::ConcurrentHashMap::reserve() - avoid setting count to 0

Summary: folly::ConcurrentHashMap::reserve() - avoid setting count to 0

Reviewed By: magedm

Differential Revision: D25398175

fbshipit-source-id: fc61b27d145f0d800cba9d35c942c0a5c8b53e2a
parent cea6de83
...@@ -464,6 +464,8 @@ class ConcurrentHashMap { ...@@ -464,6 +464,8 @@ class ConcurrentHashMap {
void reserve(size_t count) { void reserve(size_t count) {
count = count >> ShardBits; count = count >> ShardBits;
if (!count)
return;
for (uint64_t i = 0; i < NumShards; i++) { for (uint64_t i = 0; i < NumShards; i++) {
auto seg = segments_[i].load(std::memory_order_acquire); auto seg = segments_[i].load(std::memory_order_acquire);
if (seg) { if (seg) {
......
...@@ -193,6 +193,7 @@ TYPED_TEST_P(ConcurrentHashMapTest, MapResizeTest) { ...@@ -193,6 +193,7 @@ TYPED_TEST_P(ConcurrentHashMapTest, MapResizeTest) {
if (res != foomap.cend()) { if (res != foomap.cend()) {
EXPECT_EQ(0, res->second); EXPECT_EQ(0, res->second);
} }
foomap.reserve(0);
} }
// Ensure we can insert objects without copy constructors. // Ensure we can insert objects without copy constructors.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment