More call set->next() directly

This commit is contained in:
Behdad Esfahbod 2022-11-24 14:56:04 -07:00
parent 196c9db06f
commit 06e2147a48
1 changed files with 14 additions and 15 deletions

View File

@ -1645,11 +1645,10 @@ struct ClassDefFormat1_3
bool intersects (const hb_set_t *glyphs) const bool intersects (const hb_set_t *glyphs) const
{ {
/* TODO Speed up, using hb_set_next()? */
hb_codepoint_t start = startGlyph; hb_codepoint_t start = startGlyph;
hb_codepoint_t end = startGlyph + classValue.len; hb_codepoint_t end = startGlyph + classValue.len;
for (hb_codepoint_t iter = startGlyph - 1; for (hb_codepoint_t iter = startGlyph - 1;
hb_set_next (glyphs, &iter) && iter < end;) glyphs->next (&iter) && iter < end;)
if (classValue[iter - start]) return true; if (classValue[iter - start]) return true;
return false; return false;
} }
@ -1660,10 +1659,10 @@ struct ClassDefFormat1_3
{ {
/* Match if there's any glyph that is not listed! */ /* Match if there's any glyph that is not listed! */
hb_codepoint_t g = HB_SET_VALUE_INVALID; hb_codepoint_t g = HB_SET_VALUE_INVALID;
if (!hb_set_next (glyphs, &g)) return false; if (!glyphs->next (&g)) return false;
if (g < startGlyph) return true; if (g < startGlyph) return true;
g = startGlyph + count - 1; g = startGlyph + count - 1;
if (hb_set_next (glyphs, &g)) return true; if (glyphs->next (&g)) return true;
/* Fall through. */ /* Fall through. */
} }
/* TODO Speed up, using set overlap first? */ /* TODO Speed up, using set overlap first? */
@ -1682,11 +1681,11 @@ struct ClassDefFormat1_3
{ {
unsigned start_glyph = startGlyph; unsigned start_glyph = startGlyph;
for (uint32_t g = HB_SET_VALUE_INVALID; for (uint32_t g = HB_SET_VALUE_INVALID;
hb_set_next (glyphs, &g) && g < start_glyph;) glyphs->next (&g) && g < start_glyph;)
intersect_glyphs->add (g); intersect_glyphs->add (g);
for (uint32_t g = startGlyph + count - 1; for (uint32_t g = startGlyph + count - 1;
hb_set_next (glyphs, &g);) glyphs-> next (&g);)
intersect_glyphs->add (g); intersect_glyphs->add (g);
return; return;
@ -1702,7 +1701,7 @@ struct ClassDefFormat1_3
unsigned start_glyph = startGlyph; unsigned start_glyph = startGlyph;
unsigned end_glyph = start_glyph + count; unsigned end_glyph = start_glyph + count;
for (unsigned g = startGlyph - 1; for (unsigned g = startGlyph - 1;
hb_set_next (glyphs, &g) && g < end_glyph;) glyphs->next (&g) && g < end_glyph;)
if (classValue.arrayZ[g - start_glyph] == klass) if (classValue.arrayZ[g - start_glyph] == klass)
intersect_glyphs->add (g); intersect_glyphs->add (g);
#endif #endif
@ -1898,13 +1897,13 @@ struct ClassDefFormat2_4
hb_codepoint_t g = HB_SET_VALUE_INVALID; hb_codepoint_t g = HB_SET_VALUE_INVALID;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
if (!hb_set_next (glyphs, &g)) if (!glyphs->next (&g))
break; break;
if (g < rangeRecord[i].first) if (g < rangeRecord[i].first)
return true; return true;
g = rangeRecord[i].last; g = rangeRecord[i].last;
} }
if (g != HB_SET_VALUE_INVALID && hb_set_next (glyphs, &g)) if (g != HB_SET_VALUE_INVALID && glyphs->next (&g))
return true; return true;
/* Fall through. */ /* Fall through. */
} }
@ -1922,17 +1921,17 @@ struct ClassDefFormat2_4
hb_codepoint_t g = HB_SET_VALUE_INVALID; hb_codepoint_t g = HB_SET_VALUE_INVALID;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
if (!hb_set_next (glyphs, &g)) if (!glyphs->next (&g))
goto done; goto done;
while (g < rangeRecord[i].first) while (g < rangeRecord[i].first)
{ {
intersect_glyphs->add (g); intersect_glyphs->add (g);
if (!hb_set_next (glyphs, &g)) if (!glyphs->next (&g))
goto done; goto done;
} }
g = rangeRecord[i].last; g = rangeRecord[i].last;
} }
while (hb_set_next (glyphs, &g)) while (glyphs->next (&g))
intersect_glyphs->add (g); intersect_glyphs->add (g);
done: done:
@ -1945,7 +1944,7 @@ struct ClassDefFormat2_4
if ((count >> 3) > glyphs->get_population ()) if ((count >> 3) > glyphs->get_population ())
{ {
for (hb_codepoint_t g = HB_SET_VALUE_INVALID; for (hb_codepoint_t g = HB_SET_VALUE_INVALID;
hb_set_next (glyphs, &g);) glyphs->next (&g);)
if (rangeRecord.as_array ().bfind (g)) if (rangeRecord.as_array ().bfind (g))
intersect_glyphs->add (g); intersect_glyphs->add (g);
return; return;
@ -1971,7 +1970,7 @@ struct ClassDefFormat2_4
hb_codepoint_t g = HB_SET_VALUE_INVALID; hb_codepoint_t g = HB_SET_VALUE_INVALID;
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
if (!hb_set_next (glyphs, &g)) if (!glyphs->next (&g))
break; break;
if (g < rangeRecord[i].first) if (g < rangeRecord[i].first)
{ {
@ -1980,7 +1979,7 @@ struct ClassDefFormat2_4
} }
g = rangeRecord[i].last; g = rangeRecord[i].last;
} }
if (g != HB_SET_VALUE_INVALID && hb_set_next (glyphs, &g)) if (g != HB_SET_VALUE_INVALID && glyphs->next (&g))
intersect_classes->add (0); intersect_classes->add (0);
for (const auto& record : rangeRecord.iter ()) for (const auto& record : rangeRecord.iter ())