Skip to content

Commit

Permalink
Merge pull request #211 from bpmckinnon/OptimizeEraseIf
Browse files Browse the repository at this point in the history
Optimization for parallel hash map erase_if function
  • Loading branch information
greg7mdp authored Oct 19, 2023
2 parents 9f52b30 + 749a283 commit 401552d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions parallel_hashmap/phmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -3301,12 +3301,15 @@ class parallel_hash_set
#if __cplusplus >= 201703L
static_assert(std::is_invocable<F, value_type&>::value);
#endif
L m;
auto it = this->template find<K, L>(key, this->hash(key), m);
if (it == this->end()) return false;
auto hashval = this->hash(key);
Inner& inner = sets_[subidx(hashval)];
auto& set = inner.set_;
L m(inner);
auto it = set.find(key, hashval);
if (it == set.end()) return false;
if (std::forward<F>(f)(const_cast<value_type &>(*it)))
{
this->erase(it);
set._erase(it);
return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion tests/raw_hash_set_allocator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CheckedAlloc {
std::integral_constant<bool, (Spec & kPropagateOnSwap) != 0>;

CheckedAlloc select_on_container_copy_construction() const {
if (Spec & kPropagateOnCopy) return *this;
PHMAP_IF_CONSTEXPR (Spec & kPropagateOnCopy) return *this;
return {};
}

Expand Down

0 comments on commit 401552d

Please sign in to comment.