mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-13 08:42:59 +00:00
[set] Use better hash
This commit is contained in:
parent
fe3339ea24
commit
a58bbe5408
2 changed files with 6 additions and 5 deletions
|
@ -104,10 +104,7 @@ struct hb_bit_page_t
|
|||
}
|
||||
uint32_t hash () const
|
||||
{
|
||||
return
|
||||
+ hb_iter (v)
|
||||
| hb_reduce ([] (uint32_t h, const elt_t &_) { return h * 31 + hb_hash (_); }, (uint32_t) 0u)
|
||||
;
|
||||
return hb_bytes_t ((const char *) &v, sizeof (v)).hash ();
|
||||
}
|
||||
|
||||
void add (hb_codepoint_t g) { elt (g) |= mask (g); }
|
||||
|
|
|
@ -134,7 +134,11 @@ struct hb_bit_set_t
|
|||
{
|
||||
uint32_t h = 0;
|
||||
for (auto &map : page_map)
|
||||
h = h * 31 + hb_hash (map.major) + hb_hash (pages[map.index]);
|
||||
{
|
||||
auto &page = pages.arrayZ[map.index];
|
||||
if (unlikely (page.is_empty ())) continue;
|
||||
h = h * 31 + hb_hash (map.major) + hb_hash (page);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue