[buffer] Optimize _infos_set_glyph_flags to avoid O(n^2) behavior
85be877925 (commitcomment-99547060)
This commit is contained in:
parent
0b97ac39ac
commit
30b84faba7
|
@ -580,6 +580,15 @@ struct hb_buffer_t
|
||||||
unsigned int start, unsigned int end,
|
unsigned int start, unsigned int end,
|
||||||
unsigned int cluster,
|
unsigned int cluster,
|
||||||
hb_mask_t mask)
|
hb_mask_t mask)
|
||||||
|
{
|
||||||
|
if (unlikely (start == end))
|
||||||
|
return;
|
||||||
|
|
||||||
|
unsigned cluster_first = info[start].cluster;
|
||||||
|
unsigned cluster_last = info[end - 1].cluster;
|
||||||
|
|
||||||
|
if (cluster_level == HB_BUFFER_CLUSTER_LEVEL_CHARACTERS ||
|
||||||
|
(cluster != cluster_first && cluster != cluster_last))
|
||||||
{
|
{
|
||||||
for (unsigned int i = start; i < end; i++)
|
for (unsigned int i = start; i < end; i++)
|
||||||
if (cluster != infos[i].cluster)
|
if (cluster != infos[i].cluster)
|
||||||
|
@ -587,6 +596,29 @@ struct hb_buffer_t
|
||||||
scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GLYPH_FLAGS;
|
scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GLYPH_FLAGS;
|
||||||
infos[i].mask |= mask;
|
infos[i].mask |= mask;
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Monotone clusters */
|
||||||
|
|
||||||
|
if (cluster == cluster_first)
|
||||||
|
{
|
||||||
|
for (unsigned int i = end; start < i && infos[i - 1].cluster != cluster_first; i--)
|
||||||
|
if (cluster != infos[i - 1].cluster)
|
||||||
|
{
|
||||||
|
scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GLYPH_FLAGS;
|
||||||
|
infos[i - 1].mask |= mask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else /* cluster == cluster_last */
|
||||||
|
{
|
||||||
|
for (unsigned int i = start; i < end && infos[i].cluster != cluster_last; i++)
|
||||||
|
if (cluster != infos[i].cluster)
|
||||||
|
{
|
||||||
|
scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GLYPH_FLAGS;
|
||||||
|
infos[i].mask |= mask;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
unsigned
|
unsigned
|
||||||
_infos_find_min_cluster (const hb_glyph_info_t *infos,
|
_infos_find_min_cluster (const hb_glyph_info_t *infos,
|
||||||
|
|
Loading…
Reference in New Issue