Call get_nominal_glyphs() for runs of simple clusters at a time

Even without FT or OT font funcs implementing get_nominal_glyphs(), there's measurable
speedup.
This commit is contained in:
Behdad Esfahbod 2018-10-09 14:50:57 -04:00
parent 8008bca83b
commit e883f52732
2 changed files with 28 additions and 1 deletions

View File

@ -260,7 +260,8 @@ struct hb_buffer_t
{
if (have_output)
{
if (unlikely (out_info != info || out_len != idx)) {
if (out_info != info || out_len != idx)
{
if (unlikely (!make_room_for (1, 1))) return;
out_info[out_len] = info[idx];
}
@ -269,6 +270,23 @@ struct hb_buffer_t
idx++;
}
/* Copies n glyphs at idx to output and advance idx.
* If there's no output, just advance idx. */
inline void
next_glyphs (unsigned int n)
{
if (have_output)
{
if (out_info != info || out_len != idx)
{
if (unlikely (!make_room_for (n, n))) return;
memmove (out_info + out_len, info + idx, n * sizeof (out_info[0]));
}
out_len += n;
}
idx += n;
}
/* Advance idx without copying to output. */
inline void skip_glyph (void)
{

View File

@ -335,6 +335,15 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan,
end--; /* Leave one base for the marks to cluster with. */
/* From idx to end are simple clusters. */
if (might_short_circuit)
{
unsigned int done = font->get_nominal_glyphs (end - buffer->idx,
&buffer->cur().codepoint,
sizeof (buffer->info[0]),
&buffer->cur().glyph_index(),
sizeof (buffer->info[0]));
buffer->next_glyphs (done);
}
while (buffer->idx < end && buffer->successful)
decompose_current_character (&c, might_short_circuit);