[subset-plan] Simplify name_table_overrides allocation
This commit is contained in:
parent
5cab4a55d2
commit
1426f1c8ea
|
@ -48,15 +48,7 @@ hb_subset_input_create_or_fail (void)
|
||||||
for (auto& set : input->sets_iter ())
|
for (auto& set : input->sets_iter ())
|
||||||
set = hb_set_create ();
|
set = hb_set_create ();
|
||||||
|
|
||||||
#ifdef HB_EXPERIMENTAL_API
|
if (input->in_error ())
|
||||||
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 ())
|
|
||||||
{
|
{
|
||||||
hb_subset_input_destroy (input);
|
hb_subset_input_destroy (input);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -253,12 +245,8 @@ hb_subset_input_destroy (hb_subset_input_t *input)
|
||||||
hb_set_destroy (set);
|
hb_set_destroy (set);
|
||||||
|
|
||||||
#ifdef HB_EXPERIMENTAL_API
|
#ifdef HB_EXPERIMENTAL_API
|
||||||
if (input->name_table_overrides)
|
for (auto _ : input->name_table_overrides)
|
||||||
{
|
|
||||||
for (auto _ : *input->name_table_overrides)
|
|
||||||
_.second.fini ();
|
_.second.fini ();
|
||||||
}
|
|
||||||
hb_hashmap_destroy (input->name_table_overrides);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hb_free (input);
|
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);
|
hb_memcpy (override_name, name_str, str_len);
|
||||||
name_bytes = hb_bytes_t (override_name, 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ struct hb_subset_input_t
|
||||||
|
|
||||||
hb_hashmap_t<hb_tag_t, float> axes_location;
|
hb_hashmap_t<hb_tag_t, float> axes_location;
|
||||||
#ifdef HB_EXPERIMENTAL_API
|
#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
|
#endif
|
||||||
|
|
||||||
inline unsigned num_sets () const
|
inline unsigned num_sets () const
|
||||||
|
@ -131,7 +131,7 @@ struct hb_subset_input_t
|
||||||
|
|
||||||
return axes_location.in_error ()
|
return axes_location.in_error ()
|
||||||
#ifdef HB_EXPERIMENTAL_API
|
#ifdef HB_EXPERIMENTAL_API
|
||||||
|| name_table_overrides->in_error ()
|
|| name_table_overrides.in_error ()
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -862,9 +862,7 @@ hb_subset_plan_create_or_fail (hb_face_t *face,
|
||||||
plan->pinned_at_default = true;
|
plan->pinned_at_default = true;
|
||||||
|
|
||||||
#ifdef HB_EXPERIMENTAL_API
|
#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;
|
hb_bytes_t name_bytes = _.second;
|
||||||
unsigned len = name_bytes.length;
|
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);
|
hb_memcpy (name_str, name_bytes.arrayZ, len);
|
||||||
plan->name_table_overrides.set (_.first, hb_bytes_t (name_str, len));
|
plan->name_table_overrides.set (_.first, hb_bytes_t (name_str, len));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void* accel = hb_face_get_user_data(face, hb_subset_accelerator_t::user_data_key());
|
void* accel = hb_face_get_user_data(face, hb_subset_accelerator_t::user_data_key());
|
||||||
|
|
Loading…
Reference in New Issue