From 8a18882ca73f8282069087537d6c5f45c3131664 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 18 Nov 2021 22:02:51 -0500 Subject: [PATCH] Revert "Fix (hopefully) part #2 of issue #117 for non-parallel hash maps" This reverts commit 3f02d819260885fd6380c389a13b7b55e050e599. --- parallel_hashmap/phmap.h | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/parallel_hashmap/phmap.h b/parallel_hashmap/phmap.h index 93e692e..2736290 100644 --- a/parallel_hashmap/phmap.h +++ b/parallel_hashmap/phmap.h @@ -1441,17 +1441,6 @@ public: 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 iterator lazy_emplace(const key_arg& key, F&& f) { auto res = find_or_prepare_insert(key); @@ -2093,7 +2082,7 @@ private: protected: template - fpi_result find_or_prepare_insert(const K& key, size_t hashval) { + std::pair find_or_prepare_insert(const K& key, size_t hashval) { auto seq = probe(hashval); while (true) { Group g{ctrl_ + seq.offset()}; @@ -2101,16 +2090,16 @@ protected: if (PHMAP_PREDICT_TRUE(PolicyTraits::apply( EqualElement{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 - fpi_result find_or_prepare_insert(const K& key) { + std::pair find_or_prepare_insert(const K& key) { return find_or_prepare_insert(key, this->hash(key)); } @@ -2123,6 +2112,7 @@ protected: } ++size_; growth_left() -= IsEmpty(ctrl_[target.offset]); + set_ctrl(target.offset, H2(hashval)); infoz_.RecordInsert(hashval, target.probe_length); return target.offset; }