[subset] Reuse num_glyphs in various places

This commit is contained in:
Behdad Esfahbod 2023-06-03 22:24:06 -06:00
parent 7e4311a868
commit b5792f117a
4 changed files with 11 additions and 6 deletions

View file

@ -545,7 +545,8 @@ struct IndexSubtableArray
const IndexSubtableRecord*>> *lookup /* OUT */) const
{
bool start_glyph_is_set = false;
for (hb_codepoint_t new_gid = 0; new_gid < c->plan->num_output_glyphs (); new_gid++)
unsigned num_glyphs = c->plan->num_output_glyphs ();
for (hb_codepoint_t new_gid = 0; new_gid < num_glyphs; new_gid++)
{
hb_codepoint_t old_gid;
if (unlikely (!c->plan->old_gid_for_new_gid (new_gid, &old_gid))) continue;

View file

@ -201,7 +201,8 @@ struct hvarvvar_subset_plan_t
if (retain_adv_map)
{
for (hb_codepoint_t gid = 0; gid < plan->num_output_glyphs (); gid++)
unsigned num_glyphs = plan->num_output_glyphs ();
for (hb_codepoint_t gid = 0; gid < num_glyphs; gid++)
{
if (inner_sets[0]->has (gid))
inner_maps[0].add (gid);

View file

@ -709,7 +709,8 @@ struct subr_subsetter_t
}
/* phase 1 & 2 */
for (unsigned int i = 0; i < plan->num_output_glyphs (); i++)
unsigned num_glyphs = plan->num_output_glyphs ();
for (unsigned int i = 0; i < num_glyphs; i++)
{
hb_codepoint_t glyph;
if (!plan->old_gid_for_new_gid (i, &glyph))
@ -987,7 +988,8 @@ struct subr_subsetter_t
const hb_vector_t<parsed_cs_str_vec_t>& local_subrs)
{
closures.reset ();
for (unsigned int i = 0; i < plan->num_output_glyphs (); i++)
unsigned num_glyphs = plan->num_output_glyphs ();
for (unsigned int i = 0; i < num_glyphs; i++)
{
hb_codepoint_t glyph;
if (!plan->old_gid_for_new_gid (i, &glyph))

View file

@ -415,7 +415,8 @@ struct cff_subset_plan {
subset_enc_num_codes = plan->num_output_glyphs () - 1;
unsigned int glyph;
for (glyph = 1; glyph < plan->num_output_glyphs (); glyph++)
unsigned num_glyphs = plan->num_output_glyphs ();
for (glyph = 1; glyph < num_glyphs; glyph++)
{
hb_codepoint_t old_glyph;
if (!plan->old_gid_for_new_gid (glyph, &old_glyph))
@ -574,7 +575,7 @@ struct cff_subset_plan {
/* check whether the subset renumbers any glyph IDs */
gid_renum = false;
for (hb_codepoint_t new_glyph = 0; new_glyph < plan->num_output_glyphs (); new_glyph++)
for (hb_codepoint_t new_glyph = 0; new_glyph < num_glyphs; new_glyph++)
{
if (!plan->old_gid_for_new_gid(new_glyph, &old_glyph))
continue;