[cmap] Convert another map use to unique_ptr

This commit is contained in:
Behdad Esfahbod 2022-06-02 18:59:15 -06:00
parent 997d9cc466
commit a7a688616a
1 changed files with 2 additions and 11 deletions

View File

@ -1476,26 +1476,17 @@ struct SubtableUnicodesCache {
private:
const void* base;
hb_hashmap_t<intptr_t, hb_set_t*> cached_unicodes;
hb_hashmap_t<intptr_t, hb::unique_ptr<hb_set_t>> cached_unicodes;
public:
SubtableUnicodesCache(const void* cmap_base)
: base(cmap_base), cached_unicodes() {}
~SubtableUnicodesCache()
{
for (hb_set_t* s : cached_unicodes.values()) {
hb_set_destroy (s);
}
}
hb_set_t* set_for(const EncodingRecord* record)
{
if (!cached_unicodes.has ((intptr_t) record)) {
hb_set_t* new_set = hb_set_create ();
if (!cached_unicodes.set ((intptr_t) record, new_set)) {
hb_set_destroy (new_set);
if (!cached_unicodes.set ((intptr_t) record, hb::unique_ptr<hb_set_t> {hb_set_create ()}))
return hb_set_get_empty ();
}
(base+record->subtable).collect_unicodes (cached_unicodes.get ((intptr_t) record));
}
return cached_unicodes.get ((intptr_t) record);