[map] Don't set out value in has() if not found

This commit is contained in:
Behdad Esfahbod 2022-07-20 14:38:28 -06:00
parent 485f043211
commit 00cfc5c17d
1 changed files with 0 additions and 6 deletions

View File

@ -222,10 +222,7 @@ struct hb_hashmap_t
bool has (K key, const V **vp = nullptr) const bool has (K key, const V **vp = nullptr) const
{ {
if (unlikely (!items)) if (unlikely (!items))
{
if (vp) *vp = &item_t::default_value ();
return false; return false;
}
unsigned int i = bucket_for (key); unsigned int i = bucket_for (key);
if (items[i].is_real () && items[i] == key) if (items[i].is_real () && items[i] == key)
{ {
@ -233,10 +230,7 @@ struct hb_hashmap_t
return true; return true;
} }
else else
{
if (vp) *vp = &item_t::default_value ();
return false; return false;
}
} }
/* Projection. */ /* Projection. */
V operator () (K k) const { return get (k); } V operator () (K k) const { return get (k); }