Skip to content

Commit

Permalink
Revert "Fix (hopefully) part #2 of issue #117 for non-parallel hash m…
Browse files Browse the repository at this point in the history
…aps"

This reverts commit 3f02d81.
  • Loading branch information
greg7mdp committed Nov 19, 2021
1 parent 3f02d81 commit 8a18882
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions parallel_hashmap/phmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -1441,17 +1441,6 @@ class raw_hash_set
slot_type** slot_;
};

struct fpi_result
{
~fpi_result() { if (second) set->set_ctrl(first, H2(hashval)); }

raw_hash_set *set;
size_t hashval;
size_t first;
bool second;
};


template <class K = key_type, class F>
iterator lazy_emplace(const key_arg<K>& key, F&& f) {
auto res = find_or_prepare_insert(key);
Expand Down Expand Up @@ -2093,24 +2082,24 @@ class raw_hash_set

protected:
template <class K>
fpi_result find_or_prepare_insert(const K& key, size_t hashval) {
std::pair<size_t, bool> find_or_prepare_insert(const K& key, size_t hashval) {
auto seq = probe(hashval);
while (true) {
Group g{ctrl_ + seq.offset()};
for (int i : g.Match((h2_t)H2(hashval))) {
if (PHMAP_PREDICT_TRUE(PolicyTraits::apply(
EqualElement<K>{key, eq_ref()},
PolicyTraits::element(slots_ + seq.offset((size_t)i)))))
return {this, hashval, seq.offset((size_t)i), false};
return {seq.offset((size_t)i), false};
}
if (PHMAP_PREDICT_TRUE(g.MatchEmpty())) break;
seq.next();
}
return {this, hashval, prepare_insert(hashval), true};
return {prepare_insert(hashval), true};
}

template <class K>
fpi_result find_or_prepare_insert(const K& key) {
std::pair<size_t, bool> find_or_prepare_insert(const K& key) {
return find_or_prepare_insert(key, this->hash(key));
}

Expand All @@ -2123,6 +2112,7 @@ class raw_hash_set
}
++size_;
growth_left() -= IsEmpty(ctrl_[target.offset]);
set_ctrl(target.offset, H2(hashval));
infoz_.RecordInsert(hashval, target.probe_length);
return target.offset;
}
Expand Down

0 comments on commit 8a18882

Please sign in to comment.