From e883f52732a25f5495ec30656489954afd8cc3a4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 9 Oct 2018 14:50:57 -0400 Subject: [PATCH] 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. --- src/hb-buffer.hh | 20 +++++++++++++++++++- src/hb-ot-shape-normalize.cc | 9 +++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/hb-buffer.hh b/src/hb-buffer.hh index 9126822eb..9628ddae0 100644 --- a/src/hb-buffer.hh +++ b/src/hb-buffer.hh @@ -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) { diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc index 3d62e44b4..a8229a98d 100644 --- a/src/hb-ot-shape-normalize.cc +++ b/src/hb-ot-shape-normalize.cc @@ -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);