Use hb_zip() some more

This commit is contained in:
Behdad Esfahbod 2019-01-09 09:57:36 -08:00
parent f0dd0656b8
commit 83ad0b6d0f
1 changed files with 10 additions and 26 deletions

View File

@ -351,22 +351,16 @@ struct MultipleSubstFormat1
void closure (hb_closure_context_t *c) const
{
unsigned int count = sequence.len;
for (/*TODO(C++11)auto*/Coverage::iter_t iter = (this+coverage).iter (); iter; iter++)
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
if (c->glyphs->has (iter.get_glyph ()))
(this+sequence[iter.get_coverage ()]).closure (c);
}
for (auto it = hb_zip (this+coverage, sequence); it; ++it)
if (c->glyphs->has (it->first))
(this+it->second).closure (c);
}
void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
unsigned int count = sequence.len;
for (unsigned int i = 0; i < count; i++)
(this+sequence[i]).collect_glyphs (c);
for (auto it = hb_zip (this+coverage, sequence); it; ++it)
(this+it->second).collect_glyphs (c);
}
const Coverage &get_coverage () const { return this+coverage; }
@ -531,26 +525,16 @@ struct AlternateSubstFormat1
void closure (hb_closure_context_t *c) const
{
unsigned int count = alternateSet.len;
for (/*TODO(C++11)auto*/Coverage::iter_t iter = (this+coverage).iter (); iter; iter++)
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
if (c->glyphs->has (iter.get_glyph ()))
(this+alternateSet[iter.get_coverage ()]).closure (c);
}
for (auto it = hb_zip (this+coverage, alternateSet); it; ++it)
if (c->glyphs->has (it->first))
(this+it->second).closure (c);
}
void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
unsigned int count = alternateSet.len;
for (/*TODO(C++11)auto*/Coverage::iter_t iter = (this+coverage).iter (); iter; iter++)
{
if (unlikely (iter.get_coverage () >= count))
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
(this+alternateSet[iter.get_coverage ()]).collect_glyphs (c);
}
for (auto it = hb_zip (this+coverage, alternateSet); it; ++it)
(this+it->second).collect_glyphs (c);
}
const Coverage &get_coverage () const { return this+coverage; }