Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization for parallel hash map erase_if function #211

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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