From 0969614865a8664aaa13759e2d60caab0bd7df3a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 26 Jun 2021 08:52:53 -0600 Subject: [PATCH] [ot-shape] Rewrite loop without foreach_grapheme() We were not using the graphemes, and that's costlier than just for(). --- src/hb-ot-shape.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 97958afe7..9fede0355 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -588,9 +588,10 @@ hb_ensure_native_direction (hb_buffer_t *buffer) { bool found_number = false, found_letter = false; const auto* info = buffer->info; - foreach_grapheme (buffer, start, end) + const auto count = buffer->len; + for (unsigned i = 0; i < count; i++) { - auto gc = _hb_glyph_info_get_general_category (&info[start]); + auto gc = _hb_glyph_info_get_general_category (&info[i]); if (gc == HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER) found_number = true; else if (HB_UNICODE_GENERAL_CATEGORY_IS_LETTER (gc))