From e91863b7173543b850e1758873f96c76c67f8ce8 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 18 May 2022 12:39:55 -0600 Subject: [PATCH] [subset-cff] Pre-size map in subr_remap_t::create() --- src/hb-bimap.hh | 6 ++++++ src/hb-subset-cff-common.hh | 1 + 2 files changed, 7 insertions(+) diff --git a/src/hb-bimap.hh b/src/hb-bimap.hh index a9e1278de..5b313bf59 100644 --- a/src/hb-bimap.hh +++ b/src/hb-bimap.hh @@ -39,6 +39,12 @@ struct hb_bimap_t back_map.reset (); } + void resize (unsigned pop) + { + forw_map.resize (pop); + back_map.resize (pop); + } + bool in_error () const { return forw_map.in_error () || back_map.in_error (); } void set (hb_codepoint_t lhs, hb_codepoint_t rhs) diff --git a/src/hb-subset-cff-common.hh b/src/hb-subset-cff-common.hh index 0a24526f5..ae155b4e3 100644 --- a/src/hb-subset-cff-common.hh +++ b/src/hb-subset-cff-common.hh @@ -466,6 +466,7 @@ struct subr_remap_t : hb_inc_bimap_t * no optimization based on usage counts. fonttools doesn't appear doing that either. */ + resize (closure->get_population ()); hb_codepoint_t old_num = HB_SET_VALUE_INVALID; while (hb_set_next (closure, &old_num)) add (old_num);