From c503cf003e75191f3b3f9200c8dc4e90fdc1c67b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 28 Nov 2022 15:53:35 -0700 Subject: [PATCH] [cmap] Store offset, not pointer, in cmap cache --- src/hb-ot-cmap-table.hh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index 09c9fe93f..44f3e5f2a 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -1477,16 +1477,16 @@ struct EncodingRecord struct SubtableUnicodesCache { private: - const void* base; - hb_hashmap_t> cached_unicodes; + const char* base; + hb_hashmap_t> cached_unicodes; public: 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) { - if (!cached_unicodes.has ((intptr_t) record)) + if (!cached_unicodes.has ((unsigned) ((const char *) record - base))) { hb_set_t *s = hb_set_create (); if (unlikely (s->in_error ())) @@ -1494,12 +1494,12 @@ struct SubtableUnicodesCache { (base+record->subtable).collect_unicodes (s); - if (unlikely (!cached_unicodes.set ((intptr_t) record, hb::unique_ptr {s}))) + if (unlikely (!cached_unicodes.set ((unsigned) ((const char *) record - base), hb::unique_ptr {s}))) return hb_set_get_empty (); return s; } - return cached_unicodes.get ((intptr_t) record); + return cached_unicodes.get ((unsigned) ((const char *) record - base)); } };