[set/map] Adjust hash function return type

This commit is contained in:
Behdad Esfahbod 2022-05-19 15:42:54 -06:00
parent 6544fc284f
commit 58f848daa8
5 changed files with 11 additions and 11 deletions

View File

@ -40,15 +40,15 @@ struct hb_bit_page_t
bool is_empty () const
{
for (unsigned int i = 0; i < len (); i++)
for (unsigned i = 0; i < len (); i++)
if (v[i])
return false;
return true;
}
unsigned hash () const
uint32_t hash () const
{
unsigned h = 0;
for (unsigned int i = 0; i < len (); i++)
uint32_t h = 0;
for (unsigned i = 0; i < len (); i++)
h = h * 31 + hb_hash (v[i]);
return h;
}

View File

@ -80,7 +80,7 @@ struct hb_bit_set_invertible_t
next (&v);
return v == INVALID;
}
unsigned hash () const { return s.hash () ^ inverted; }
uint32_t hash () const { return s.hash () ^ inverted; }
hb_codepoint_t get_min () const
{

View File

@ -80,7 +80,7 @@ struct hb_bit_set_t
bool successful = true; /* Allocations successful */
mutable unsigned int population = 0;
mutable unsigned int hash_ = 0;
mutable uint32_t hash_ = 0;
mutable unsigned int last_page_lookup = 0;
hb_sorted_vector_t<page_map_t> page_map;
hb_vector_t<page_t> pages;
@ -133,11 +133,11 @@ struct hb_bit_set_t
explicit operator bool () const { return !is_empty (); }
bool has_hash () const { return hash_ != UINT_MAX; }
unsigned hash () const
uint32_t hash () const
{
if (has_hash ()) return hash_;
unsigned h = 0;
uint32_t h = 0;
for (auto &map : page_map)
h = h * 31 + hb_hash (map.major) + hb_hash (pages[map.index]);

View File

@ -239,9 +239,9 @@ struct hb_hashmap_t
bool is_empty () const { return population == 0; }
explicit operator bool () const { return !is_empty (); }
unsigned hash () const
uint32_t hash () const
{
unsigned h = 0;
uint32_t h = 0;
for (auto pair : iter ())
h ^= hb_hash (pair.first) ^ hb_hash (pair.second);
return h;

View File

@ -82,7 +82,7 @@ struct hb_sparseset_t
void clear () { s.clear (); }
void invert () { s.invert (); }
bool is_empty () const { return s.is_empty (); }
unsigned hash () const { return s.hash (); }
uint32_t hash () const { return s.hash (); }
void add (hb_codepoint_t g) { s.add (g); }
bool add_range (hb_codepoint_t a, hb_codepoint_t b) { return s.add_range (a, b); }