diff --git a/src/hb-object-private.hh b/src/hb-object-private.hh index 1f49885445964e995583d5dffd3d351d6af09c90..77e0089103ddc1602a2ce9dc7a061b9149559c61 100644 --- a/src/hb-object-private.hh +++ b/src/hb-object-private.hh @@ -125,6 +125,8 @@ struct hb_user_data_array_t { map.unset (key); return true; } + if (!key) + return false; hb_user_data_t user_data = {data, destroy}; return map.set (key, user_data); } diff --git a/src/hb-private.hh b/src/hb-private.hh index 1d40d66e487bcde0b872fccd595d5ecae43708e1..9a23cd3efeebdb41ced8d592d7619d2bd3520cb6 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -300,20 +300,20 @@ struct hb_map_t private: - inline item_t *find (Key key) { - if (unlikely (!key)) return NULL; + template + inline item_t *find (T key) { for (unsigned int i = 0; i < items.len; i++) - if (key == items[i].key) + if (items[i].key == key) return &items[i]; return NULL; } public: - inline bool set (Key key, + template + inline bool set (T key, Value &value) { - if (unlikely (!key)) return NULL; item_t *item; item = find (key); if (item) @@ -337,7 +337,8 @@ struct hb_map_t items.pop (); } - inline Value *get (Key key) + template + inline Value *get (T key) { item_t *item = find (key); return item ? &item->value : NULL;