[ClassDef] Optimize intersected_class_glyphs

This commit is contained in:
Behdad Esfahbod 2022-11-29 21:14:44 -07:00
parent 44c585a6df
commit ccd40c842c
1 changed files with 6 additions and 8 deletions

View File

@ -1954,13 +1954,13 @@ struct ClassDefFormat2_4
{ {
if (!glyphs->next (&g)) if (!glyphs->next (&g))
goto done; goto done;
while (g < rangeRecord[i].first) while (g < rangeRecord.arrayZ[i].first)
{ {
intersect_glyphs->add (g); intersect_glyphs->add (g);
if (!glyphs->next (&g)) if (!glyphs->next (&g))
goto done; goto done;
} }
g = rangeRecord[i].last; g = rangeRecord.arrayZ[i].last;
} }
while (glyphs->next (&g)) while (glyphs->next (&g))
intersect_glyphs->add (g); intersect_glyphs->add (g);
@ -1969,9 +1969,7 @@ struct ClassDefFormat2_4
return; return;
} }
/* The following implementation is faster asymptotically, but slower if (count > glyphs->get_population () * hb_bit_storage (count) * 8)
* in practice. */
if (false && count > glyphs->get_population () * hb_bit_storage (count))
{ {
for (hb_codepoint_t g = HB_SET_VALUE_INVALID; for (hb_codepoint_t g = HB_SET_VALUE_INVALID;
glyphs->next (&g);) glyphs->next (&g);)
@ -1986,10 +1984,10 @@ struct ClassDefFormat2_4
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
if (rangeRecord[i].value != klass) continue; if (rangeRecord.arrayZ[i].value != klass) continue;
unsigned end = rangeRecord[i].last + 1; unsigned end = rangeRecord.arrayZ[i].last + 1;
for (hb_codepoint_t g = rangeRecord[i].first - 1; for (hb_codepoint_t g = rangeRecord.arrayZ[i].first - 1;
glyphs->next (&g) && g < end;) glyphs->next (&g) && g < end;)
intersect_glyphs->add (g); intersect_glyphs->add (g);
} }