From 75b33cb04b783f9f8473df46b603b6e94dc226b3 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 11 Jan 2023 12:24:35 -0700 Subject: [PATCH] [subset-plan] Simplify hmtx_map / vmtx_map allocation --- src/OT/glyf/Glyph.hh | 4 ++-- src/hb-ot-hmtx-table.hh | 2 +- src/hb-subset-plan.cc | 3 --- src/hb-subset-plan.hh | 6 ++---- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/OT/glyf/Glyph.hh b/src/OT/glyf/Glyph.hh index 6dba69a7b..155a4b5d3 100644 --- a/src/OT/glyf/Glyph.hh +++ b/src/OT/glyf/Glyph.hh @@ -96,12 +96,12 @@ struct Glyph unsigned hori_aw = roundf (rightSideX - leftSideX); if (hori_aw < 0) hori_aw = 0; int lsb = roundf (xMin - leftSideX); - plan->hmtx_map->set (new_gid, hb_pair (hori_aw, lsb)); + plan->hmtx_map.set (new_gid, hb_pair (hori_aw, lsb)); unsigned vert_aw = roundf (topSideY - bottomSideY); if (vert_aw < 0) vert_aw = 0; int tsb = roundf (topSideY - yMax); - plan->vmtx_map->set (new_gid, hb_pair (vert_aw, tsb)); + plan->vmtx_map.set (new_gid, hb_pair (vert_aw, tsb)); } bool compile_header_bytes (const hb_subset_plan_t *plan, diff --git a/src/hb-ot-hmtx-table.hh b/src/hb-ot-hmtx-table.hh index fc759c178..f20fb55fb 100644 --- a/src/hb-ot-hmtx-table.hh +++ b/src/hb-ot-hmtx-table.hh @@ -74,7 +74,7 @@ struct hmtxvmtx } const hb_hashmap_t>* get_mtx_map (const hb_subset_plan_t *plan) const - { return T::is_horizontal ? plan->hmtx_map : plan->vmtx_map; } + { return T::is_horizontal ? &plan->hmtx_map : &plan->vmtx_map; } bool subset_update_header (hb_subset_plan_t *plan, unsigned int num_hmetrics) const diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 414c2ffef..0cfed1a3d 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -867,9 +867,6 @@ hb_subset_plan_create_or_fail (hb_face_t *face, plan->all_axes_pinned = false; plan->pinned_at_default = true; - plan->check_success (plan->vmtx_map = hb_hashmap_create> ()); - plan->check_success (plan->hmtx_map = hb_hashmap_create> ()); - #ifdef HB_EXPERIMENTAL_API plan->check_success (plan->name_table_overrides = hb_hashmap_create ()); if (plan->name_table_overrides && input->name_table_overrides) diff --git a/src/hb-subset-plan.hh b/src/hb-subset-plan.hh index 3f8141090..222b36ef8 100644 --- a/src/hb-subset-plan.hh +++ b/src/hb-subset-plan.hh @@ -58,8 +58,6 @@ struct hb_subset_plan_t hb_map_destroy (axes_old_index_tag_map); hb_hashmap_destroy (axes_location); - hb_hashmap_destroy (hmtx_map); - hb_hashmap_destroy (vmtx_map); #ifdef HB_EXPERIMENTAL_API if (name_table_overrides) @@ -172,9 +170,9 @@ struct hb_subset_plan_t bool has_seac; //hmtx metrics map: new gid->(advance, lsb) - hb_hashmap_t> *hmtx_map; + mutable hb_hashmap_t> hmtx_map; //vmtx metrics map: new gid->(advance, lsb) - hb_hashmap_t> *vmtx_map; + mutable hb_hashmap_t> vmtx_map; #ifdef HB_EXPERIMENTAL_API // name table overrides map: hb_ot_name_record_ids_t-> name string new value or