[map] Speed up map's own hash()
This commit is contained in:
parent
de33ef61b7
commit
cbcdf442c5
|
@ -100,6 +100,9 @@ struct hb_hashmap_t
|
||||||
return key != kinv && value != vinv;
|
return key != kinv && value != vinv;
|
||||||
}
|
}
|
||||||
hb_pair_t<K, V> get_pair() const { return hb_pair_t<K, V> (key, value); }
|
hb_pair_t<K, V> get_pair() const { return hb_pair_t<K, V> (key, value); }
|
||||||
|
|
||||||
|
uint32_t total_hash () const
|
||||||
|
{ return (hash * 31) + hb_hash (value); }
|
||||||
};
|
};
|
||||||
|
|
||||||
hb_object_header_t header;
|
hb_object_header_t header;
|
||||||
|
@ -242,9 +245,9 @@ struct hb_hashmap_t
|
||||||
uint32_t hash () const
|
uint32_t hash () const
|
||||||
{
|
{
|
||||||
uint32_t h = 0;
|
uint32_t h = 0;
|
||||||
/* TODO: Speed-up since we have the hash of the key already in the item. */
|
for (const auto &item : + hb_array (items, mask ? mask + 1 : 0)
|
||||||
for (auto pair : iter ())
|
| hb_filter (&item_t::is_real))
|
||||||
h ^= (hb_hash (pair.first) * 31) + hb_hash (pair.second);
|
h ^= item.total_hash ();
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue