[set] Fix hb_set_t hash stability
This commit is contained in:
parent
2d0b1248b2
commit
844ac328e4
|
@ -49,7 +49,7 @@ struct hb_bit_page_t
|
||||||
{
|
{
|
||||||
unsigned h = 0;
|
unsigned h = 0;
|
||||||
for (unsigned int i = 0; i < len (); i++)
|
for (unsigned int i = 0; i < len (); i++)
|
||||||
h ^= hb_hash (v[i] ^ i);
|
h = h * 31 + hb_hash (v[i]);
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,6 @@ struct hb_bit_set_t
|
||||||
{
|
{
|
||||||
int cmp (const page_map_t &o) const { return cmp (o.major); }
|
int cmp (const page_map_t &o) const { return cmp (o.major); }
|
||||||
int cmp (uint32_t o_major) const { return (int) o_major - (int) major; }
|
int cmp (uint32_t o_major) const { return (int) o_major - (int) major; }
|
||||||
unsigned hash () const { return major ^ index; }
|
|
||||||
|
|
||||||
uint32_t major;
|
uint32_t major;
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
|
@ -129,7 +128,10 @@ struct hb_bit_set_t
|
||||||
|
|
||||||
unsigned hash () const
|
unsigned hash () const
|
||||||
{
|
{
|
||||||
return page_map.hash () ^ pages.hash ();
|
unsigned h = 0;
|
||||||
|
for (auto &map : page_map)
|
||||||
|
h = h * 31 + hb_hash (map.major) + hb_hash (pages[map.index]);
|
||||||
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue