From d012f9a9b3a38cc313a07780b68e6494cc8c97c0 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 18 Nov 2022 16:29:06 -0700 Subject: [PATCH] [map] Change bucket_for() to item_for() --- src/hb-map.hh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/hb-map.hh b/src/hb-map.hh index b9943142a..66c800162 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh @@ -93,8 +93,8 @@ struct hb_hashmap_t return minus_1; }; - bool operator == (const K &o) { return hb_deref (key) == hb_deref (o); } - bool operator == (const item_t &o) { return *this == o.key; } + bool operator == (const K &o) const { return hb_deref (key) == hb_deref (o); } + bool operator == (const item_t &o) const { return *this == o.key; } hb_pair_t get_pair() const { return hb_pair_t (key, value); } hb_pair_t get_pair_ref() const { return hb_pair_t (key, value); } @@ -205,8 +205,8 @@ struct hb_hashmap_t const V& get (K key) const { if (unlikely (!items)) return item_t::default_value (); - unsigned int i = bucket_for (key); - return items[i].is_real () && items[i] == key ? items[i].value : item_t::default_value (); + auto &item = item_for (key); + return item.is_real () && item == key ? item.value : item_t::default_value (); } void del (K key) { set_with_hash (key, hb_hash (key), item_t::default_value (), true); } @@ -219,10 +219,10 @@ struct hb_hashmap_t { if (unlikely (!items)) return false; - unsigned int i = bucket_for (key); - if (items[i].is_real () && items[i] == key) + auto &item = item_for (key); + if (item.is_real () && item == key) { - if (vp) *vp = std::addressof (items[i].value); + if (vp) *vp = std::addressof (item.value); return true; } else @@ -347,9 +347,9 @@ struct hb_hashmap_t return true; } - unsigned int bucket_for (const K &key) const + item_t& item_for (const K &key) const { - return bucket_for_hash (key, hb_hash (key)); + return items[bucket_for_hash (key, hb_hash (key))]; } unsigned int bucket_for_hash (const K &key, uint32_t hash) const