[buffer] Optimize _infos_find_min_cluster for monotone clusters

This commit is contained in:
Behdad Esfahbod 2023-02-06 15:17:09 -07:00
parent 8708b9e081
commit 0b97ac39ac
1 changed files with 12 additions and 4 deletions

View File

@ -588,16 +588,24 @@ struct hb_buffer_t
infos[i].mask |= mask; infos[i].mask |= mask;
} }
} }
static unsigned unsigned
_infos_find_min_cluster (const hb_glyph_info_t *infos, _infos_find_min_cluster (const hb_glyph_info_t *infos,
unsigned start, unsigned end, unsigned start, unsigned end,
unsigned cluster = UINT_MAX) unsigned cluster = UINT_MAX)
{
if (unlikely (start == end))
return cluster;
if (cluster_level == HB_BUFFER_CLUSTER_LEVEL_CHARACTERS)
{ {
for (unsigned int i = start; i < end; i++) for (unsigned int i = start; i < end; i++)
cluster = hb_min (cluster, infos[i].cluster); cluster = hb_min (cluster, infos[i].cluster);
return cluster; return cluster;
} }
return hb_min (cluster, hb_min (infos[start].cluster, infos[end - 1].cluster));
}
void clear_glyph_flags (hb_mask_t mask = 0) void clear_glyph_flags (hb_mask_t mask = 0)
{ {
for (unsigned int i = 0; i < len; i++) for (unsigned int i = 0; i < len; i++)