diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index c3cf56136..38eb95f86 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -452,10 +452,18 @@ void hb_buffer_t::merge_out_clusters (unsigned int start, unsigned int end) { + if (unlikely (start >= end)) + return; + unsigned int cluster = out_info[start].cluster; for (unsigned int i = start + 1; i < end; i++) cluster = MIN (cluster, out_info[i].cluster); + + /* Extend start */ + while (start && out_info[start - 1].cluster == out_info[start].cluster) + start--; + for (unsigned int i = start; i < end; i++) out_info[i].cluster = cluster; } diff --git a/src/hb-ot-shape-complex-misc.cc b/src/hb-ot-shape-complex-misc.cc index d93d4c672..748d4b331 100644 --- a/src/hb-ot-shape-complex-misc.cc +++ b/src/hb-ot-shape-complex-misc.cc @@ -178,8 +178,6 @@ _hb_ot_shape_complex_setup_masks_thai (hb_ot_map_t *map HB_UNUSED, /* XXX Make this easier! */ /* Make cluster */ - for (; start > 0 && buffer->out_info[start - 1].cluster == buffer->out_info[start].cluster; start--) - ; for (; buffer->idx < count;) if (buffer->cur().cluster == buffer->prev().cluster) buffer->next_glyph ();