From a34a204bf74ee0c08a67c97444ce803d6f0a0b6d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 11 Jan 2023 12:27:19 -0700 Subject: [PATCH] [subset-plan] Simplify unicodes allocation --- src/hb-ot-cmap-table.hh | 2 +- src/hb-ot-os2-table.hh | 4 ++-- src/hb-subset-plan.cc | 9 ++++----- src/hb-subset-plan.hh | 3 +-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index 850644901..3c7d2f0a2 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -1414,7 +1414,7 @@ struct CmapSubtable switch (format) { case 4: return u.format4.serialize (c, it); case 12: return u.format12.serialize (c, it); - case 14: return u.format14.serialize (c, plan->unicodes, &plan->glyphs_requested, plan->glyph_map, base); + case 14: return u.format14.serialize (c, &plan->unicodes, &plan->glyphs_requested, plan->glyph_map, base); default: return; } } diff --git a/src/hb-ot-os2-table.hh b/src/hb-ot-os2-table.hh index 981fccb47..d63c9e0e8 100644 --- a/src/hb-ot-os2-table.hh +++ b/src/hb-ot-os2-table.hh @@ -239,11 +239,11 @@ struct OS2 /* when --gids option is not used, no need to do collect_mapping that is * iterating all codepoints in each subtable, which is not efficient */ uint16_t min_cp, max_cp; - find_min_and_max_codepoint (c->plan->unicodes, &min_cp, &max_cp); + find_min_and_max_codepoint (&c->plan->unicodes, &min_cp, &max_cp); os2_prime->usFirstCharIndex = min_cp; os2_prime->usLastCharIndex = max_cp; - _update_unicode_ranges (c->plan->unicodes, os2_prime->ulUnicodeRange); + _update_unicode_ranges (&c->plan->unicodes, os2_prime->ulUnicodeRange); return_trace (true); } diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 0cfed1a3d..3d8e0038e 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -576,7 +576,7 @@ _populate_unicodes_to_retain (const hb_set_t *unicodes, auto &arr = plan->unicode_to_new_gid_list; if (arr.length) { - plan->unicodes->add_sorted_array (&arr.arrayZ->first, arr.length, sizeof (*arr.arrayZ)); + plan->unicodes.add_sorted_array (&arr.arrayZ->first, arr.length, sizeof (*arr.arrayZ)); plan->_glyphset_gsub.add_array (&arr.arrayZ->second, arr.length, sizeof (*arr.arrayZ)); } } @@ -621,7 +621,7 @@ _populate_gids_to_retain (hb_subset_plan_t* plan, plan->_glyphset_gsub.add (0); // Not-def - _cmap_closure (plan->source, plan->unicodes, &plan->_glyphset_gsub); + _cmap_closure (plan->source, &plan->unicodes, &plan->_glyphset_gsub); #ifndef HB_NO_SUBSET_LAYOUT if (!drop_tables->has (HB_OT_TAG_GSUB)) @@ -838,7 +838,6 @@ hb_subset_plan_create_or_fail (hb_face_t *face, plan->successful = true; plan->flags = input->flags; - plan->unicodes = hb_set_create (); plan->unicode_to_new_gid_list.init (); @@ -939,7 +938,7 @@ hb_subset_plan_create_or_fail (hb_face_t *face, hb_map_t &unicode_to_gid = *plan->codepoint_to_glyph; - for (auto unicode : *plan->unicodes) + for (auto unicode : plan->unicodes) { auto gid = unicode_to_gid[unicode]; gid_to_unicodes.add (gid, unicode); @@ -948,7 +947,7 @@ hb_subset_plan_create_or_fail (hb_face_t *face, plan->inprogress_accelerator = hb_subset_accelerator_t::create (*plan->codepoint_to_glyph, gid_to_unicodes, - *plan->unicodes, + plan->unicodes, plan->has_seac); } diff --git a/src/hb-subset-plan.hh b/src/hb-subset-plan.hh index 222b36ef8..9f8e6ec51 100644 --- a/src/hb-subset-plan.hh +++ b/src/hb-subset-plan.hh @@ -48,7 +48,6 @@ struct hb_subset_plan_t ~hb_subset_plan_t() { - hb_set_destroy (unicodes); hb_face_destroy (source); hb_face_destroy (dest); hb_map_destroy (codepoint_to_glyph); @@ -82,7 +81,7 @@ struct hb_subset_plan_t bool force_long_loca = false; // For each cp that we'd like to retain maps to the corresponding gid. - hb_set_t *unicodes; + hb_set_t unicodes; hb_sorted_vector_t> unicode_to_new_gid_list; // name_ids we would like to retain