From 60418fcb95519013d1cf7ef57d9e63431401dc6a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 11 Jan 2023 12:33:25 -0700 Subject: [PATCH] [subset-plan] Simplify axes_index_map allocation --- src/hb-ot-layout-common.hh | 2 +- src/hb-ot-var-fvar-table.hh | 6 +++--- src/hb-subset-plan.cc | 3 +-- src/hb-subset-plan.hh | 3 +-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 21563220c..2c1ccea40 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -2838,7 +2838,7 @@ struct ConditionFormat1 auto *out = c->serializer->embed (this); if (unlikely (!out)) return_trace (false); - const hb_map_t *index_map = c->plan->axes_index_map; + const hb_map_t *index_map = &c->plan->axes_index_map; if (index_map->is_empty ()) return_trace (true); if (!index_map->has (axisIndex)) diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index 398c024c2..79f42cd06 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -67,7 +67,7 @@ struct InstanceRecord fabsf (axes_location->get (*axis_tag) - coords[i].to_float ()) > 0.001f) return_trace (false); - if (!c->plan->axes_index_map->has (i)) + if (!c->plan->axes_index_map.has (i)) continue; if (!c->serializer->embed (coords[i])) @@ -362,7 +362,7 @@ struct fvar bool subset (hb_subset_context_t *c) const { TRACE_SUBSET (this); - unsigned retained_axis_count = c->plan->axes_index_map->get_population (); + unsigned retained_axis_count = c->plan->axes_index_map.get_population (); if (!retained_axis_count) //all axes are pinned return_trace (false); @@ -383,7 +383,7 @@ struct fvar auto axes_records = get_axes (); for (unsigned i = 0 ; i < (unsigned)axisCount; i++) { - if (!c->plan->axes_index_map->has (i)) continue; + if (!c->plan->axes_index_map.has (i)) continue; if (unlikely (!c->serializer->embed (axes_records[i]))) return_trace (false); } diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index e8d42826a..4a229310a 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -787,7 +787,7 @@ _normalize_axes_location (hb_face_t *face, hb_subset_plan_t *plan) if (!plan->user_axes_location->has (axis_tag)) { axis_not_pinned = true; - plan->axes_index_map->set (old_axis_idx, new_axis_idx); + plan->axes_index_map.set (old_axis_idx, new_axis_idx); new_axis_idx++; } else @@ -860,7 +860,6 @@ hb_subset_plan_create_or_fail (hb_face_t *face, plan->check_success (plan->user_axes_location = hb_hashmap_create ()); if (plan->user_axes_location && input->axes_location) *plan->user_axes_location = *input->axes_location; - plan->check_success (plan->axes_index_map = hb_map_create ()); plan->all_axes_pinned = false; plan->pinned_at_default = true; diff --git a/src/hb-subset-plan.hh b/src/hb-subset-plan.hh index b60d28bde..71bb46d2d 100644 --- a/src/hb-subset-plan.hh +++ b/src/hb-subset-plan.hh @@ -55,7 +55,6 @@ struct hb_subset_plan_t hb_map_destroy (glyph_map); hb_map_destroy (reverse_glyph_map); - hb_map_destroy (axes_index_map); hb_hashmap_destroy (user_axes_location); #ifdef HB_EXPERIMENTAL_API @@ -159,7 +158,7 @@ struct hb_subset_plan_t //user specified axes location map hb_hashmap_t *user_axes_location; //retained old axis index -> new axis index mapping in fvar axis array - hb_map_t *axes_index_map; + hb_map_t axes_index_map; //axis_index->axis_tag mapping in fvar axis array hb_map_t axes_old_index_tag_map; bool all_axes_pinned;