[subset-plan] Simplify name_table_overrides allocation

This commit is contained in:
Behdad Esfahbod 2023-01-11 13:23:34 -07:00
parent 5cab4a55d2
commit 1426f1c8ea
3 changed files with 14 additions and 29 deletions

View File

@ -48,15 +48,7 @@ hb_subset_input_create_or_fail (void)
for (auto& set : input->sets_iter ())
set = hb_set_create ();
#ifdef HB_EXPERIMENTAL_API
input->name_table_overrides = hb_hashmap_create<hb_ot_name_record_ids_t, hb_bytes_t> ();
#endif
if (
#ifdef HB_EXPERIMENTAL_API
!input->name_table_overrides ||
#endif
input->in_error ())
if (input->in_error ())
{
hb_subset_input_destroy (input);
return nullptr;
@ -253,12 +245,8 @@ hb_subset_input_destroy (hb_subset_input_t *input)
hb_set_destroy (set);
#ifdef HB_EXPERIMENTAL_API
if (input->name_table_overrides)
{
for (auto _ : *input->name_table_overrides)
for (auto _ : input->name_table_overrides)
_.second.fini ();
}
hb_hashmap_destroy (input->name_table_overrides);
#endif
hb_free (input);
@ -599,7 +587,7 @@ hb_subset_input_override_name_table (hb_subset_input_t *input,
hb_memcpy (override_name, name_str, str_len);
name_bytes = hb_bytes_t (override_name, str_len);
}
input->name_table_overrides->set (hb_ot_name_record_ids_t (platform_id, encoding_id, language_id, name_id), name_bytes);
input->name_table_overrides.set (hb_ot_name_record_ids_t (platform_id, encoding_id, language_id, name_id), name_bytes);
return true;
}

View File

@ -108,7 +108,7 @@ struct hb_subset_input_t
hb_hashmap_t<hb_tag_t, float> axes_location;
#ifdef HB_EXPERIMENTAL_API
hb_hashmap_t<hb_ot_name_record_ids_t, hb_bytes_t> *name_table_overrides;
hb_hashmap_t<hb_ot_name_record_ids_t, hb_bytes_t> name_table_overrides;
#endif
inline unsigned num_sets () const
@ -131,7 +131,7 @@ struct hb_subset_input_t
return axes_location.in_error ()
#ifdef HB_EXPERIMENTAL_API
|| name_table_overrides->in_error ()
|| name_table_overrides.in_error ()
#endif
;
}

View File

@ -862,9 +862,7 @@ hb_subset_plan_create_or_fail (hb_face_t *face,
plan->pinned_at_default = true;
#ifdef HB_EXPERIMENTAL_API
if (input->name_table_overrides)
{
for (auto _ : *input->name_table_overrides)
for (auto _ : input->name_table_overrides)
{
hb_bytes_t name_bytes = _.second;
unsigned len = name_bytes.length;
@ -875,7 +873,6 @@ hb_subset_plan_create_or_fail (hb_face_t *face,
hb_memcpy (name_str, name_bytes.arrayZ, len);
plan->name_table_overrides.set (_.first, hb_bytes_t (name_str, len));
}
}
#endif
void* accel = hb_face_get_user_data(face, hb_subset_accelerator_t::user_data_key());