Revert "[map] Speed up is_real()"

This reverts commit f5307c3ba8.

Found to slow down the benchmarks in some cases.
This commit is contained in:
Garret Rieger 2022-12-05 23:57:57 +00:00
parent eda02c2ebd
commit 5e713e99bf
1 changed files with 6 additions and 9 deletions

View File

@ -65,25 +65,22 @@ struct hb_hashmap_t
struct item_t struct item_t
{ {
#define HASH_BITS 29
K key; K key;
uint32_t hash : HASH_BITS; uint32_t hash : 30;
uint32_t is_used_ : 1; uint32_t is_used_ : 1;
uint32_t is_tombstone_ : 1; uint32_t is_tombstone_ : 1;
uint32_t is_real_ : 1;
V value; V value;
item_t () : key (), item_t () : key (),
hash (0), hash (0),
is_used_ (false), is_tombstone_ (false), is_real_ (false), is_used_ (false), is_tombstone_ (false),
value () {} value () {}
bool is_used () const { return is_used_; } bool is_used () const { return is_used_; }
void set_used (bool is_used) { is_used_ = is_used; set_real (); } void set_used (bool is_used) { is_used_ = is_used; }
bool is_tombstone () const { return is_tombstone_; } bool is_tombstone () const { return is_tombstone_; }
void set_tombstone (bool is_tombstone) { is_tombstone_ = is_tombstone; set_real (); } void set_tombstone (bool is_tombstone) { is_tombstone_ = is_tombstone; }
bool is_real () const { return is_real_; } bool is_real () const { return is_used_ && !is_tombstone_; }
void set_real () { is_real_ = is_used_ && !is_tombstone_; }
template <bool v = minus_one, template <bool v = minus_one,
hb_enable_if (v == false)> hb_enable_if (v == false)>
@ -363,7 +360,7 @@ struct hb_hashmap_t
item_t& item_for_hash (const K &key, uint32_t hash) const item_t& item_for_hash (const K &key, uint32_t hash) const
{ {
hash &= (1u << HASH_BITS) - 1; hash &= 0x3FFFFFFF; // We only store lower 30bit of hash
unsigned int i = hash % prime; unsigned int i = hash % prime;
unsigned int step = 0; unsigned int step = 0;
unsigned int tombstone = (unsigned) -1; unsigned int tombstone = (unsigned) -1;