[map] Return bool from set()

This commit is contained in:
Behdad Esfahbod 2018-05-29 16:39:03 -07:00
parent e94be200bd
commit face7cf55d
1 changed files with 4 additions and 3 deletions

View File

@ -118,10 +118,10 @@ struct hb_map_t
return true; return true;
} }
inline void set (hb_codepoint_t key, hb_codepoint_t value) inline bool set (hb_codepoint_t key, hb_codepoint_t value)
{ {
if (unlikely (in_error)) return; if (unlikely (in_error)) return false;
if ((occupancy + occupancy / 2) > mask && !resize ()) return; if ((occupancy + occupancy / 2) > mask && !resize ()) return false;
unsigned int i = bucket_for (key); unsigned int i = bucket_for (key);
if (items[i].key != key) if (items[i].key != key)
{ {
@ -130,6 +130,7 @@ struct hb_map_t
items[i].key = key; items[i].key = key;
} }
items[i].value = value; items[i].value = value;
return true;
} }
inline hb_codepoint_t get (hb_codepoint_t key) const inline hb_codepoint_t get (hb_codepoint_t key) const
{ {