[cmap] Store offset, not pointer, in cmap cache

This commit is contained in:
Behdad Esfahbod 2022-11-28 15:53:35 -07:00
parent 3e151139a8
commit c503cf003e
1 changed files with 6 additions and 6 deletions

View File

@ -1477,16 +1477,16 @@ struct EncodingRecord
struct SubtableUnicodesCache { struct SubtableUnicodesCache {
private: private:
const void* base; const char* base;
hb_hashmap_t<intptr_t, hb::unique_ptr<hb_set_t>> cached_unicodes; hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> cached_unicodes;
public: public:
SubtableUnicodesCache(const void* cmap_base) SubtableUnicodesCache(const void* cmap_base)
: base(cmap_base), cached_unicodes() {} : base ((const char *) cmap_base), cached_unicodes () {}
hb_set_t* set_for (const EncodingRecord* record) hb_set_t* set_for (const EncodingRecord* record)
{ {
if (!cached_unicodes.has ((intptr_t) record)) if (!cached_unicodes.has ((unsigned) ((const char *) record - base)))
{ {
hb_set_t *s = hb_set_create (); hb_set_t *s = hb_set_create ();
if (unlikely (s->in_error ())) if (unlikely (s->in_error ()))
@ -1494,12 +1494,12 @@ struct SubtableUnicodesCache {
(base+record->subtable).collect_unicodes (s); (base+record->subtable).collect_unicodes (s);
if (unlikely (!cached_unicodes.set ((intptr_t) record, hb::unique_ptr<hb_set_t> {s}))) if (unlikely (!cached_unicodes.set ((unsigned) ((const char *) record - base), hb::unique_ptr<hb_set_t> {s})))
return hb_set_get_empty (); return hb_set_get_empty ();
return s; return s;
} }
return cached_unicodes.get ((intptr_t) record); return cached_unicodes.get ((unsigned) ((const char *) record - base));
} }
}; };