From 701112dad9f6e690b253f1e64f4e7e549f5ae65f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 22 Jul 2015 15:42:20 +0100 Subject: [PATCH] [ot] Simplify form_clusters() --- src/hb-buffer-private.hh | 9 ++++++++- src/hb-buffer.cc | 7 ++----- src/hb-ot-shape.cc | 11 +++++++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh index ced748fd..32d5a5f9 100644 --- a/src/hb-buffer-private.hh +++ b/src/hb-buffer-private.hh @@ -189,7 +189,14 @@ struct hb_buffer_t { unsigned int cluster_end); HB_INTERNAL void merge_clusters (unsigned int start, - unsigned int end); + unsigned int end) + { + if (end - start < 2) + return; + merge_clusters_impl (start, end); + } + HB_INTERNAL void merge_clusters_impl (unsigned int start, + unsigned int end); HB_INTERNAL void merge_out_clusters (unsigned int start, unsigned int end); /* Merge clusters for deleting current glyph, and skip it. */ diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index 4f953f0a..0a11fec7 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -504,16 +504,13 @@ hb_buffer_t::reverse_clusters (void) } void -hb_buffer_t::merge_clusters (unsigned int start, - unsigned int end) +hb_buffer_t::merge_clusters_impl (unsigned int start, + unsigned int end) { #ifdef HB_NO_MERGE_CLUSTERS return; #endif - if (unlikely (end - start < 2)) - return; - unsigned int cluster = info[start].cluster; for (unsigned int i = start + 1; i < end; i++) diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 8d6bb3d5..bbd044fe 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -264,11 +264,18 @@ hb_insert_dotted_circle (hb_buffer_t *buffer, hb_font_t *font) static void hb_form_clusters (hb_buffer_t *buffer) { + unsigned int base = 0; unsigned int count = buffer->len; hb_glyph_info_t *info = buffer->info; for (unsigned int i = 1; i < count; i++) - if (HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&info[i]))) - buffer->merge_clusters (i - 1, i + 1); + { + if (likely (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&info[i])))) + { + buffer->merge_clusters (base, i); + base = i; + } + } + buffer->merge_clusters (base, count); } static void -- GitLab