Avoid sort and recompose stages if all clusters simple
Even has measurable speedup...
This commit is contained in:
parent
9f79365c3b
commit
30c114ffec
|
@ -319,6 +319,7 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan,
|
||||||
|
|
||||||
/* First round, decompose */
|
/* First round, decompose */
|
||||||
|
|
||||||
|
bool all_simple = true;
|
||||||
buffer->clear_output ();
|
buffer->clear_output ();
|
||||||
count = buffer->len;
|
count = buffer->len;
|
||||||
buffer->idx = 0;
|
buffer->idx = 0;
|
||||||
|
@ -332,26 +333,29 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan,
|
||||||
if (end < count)
|
if (end < count)
|
||||||
end--; /* Leave one base for the marks to cluster with. */
|
end--; /* Leave one base for the marks to cluster with. */
|
||||||
|
|
||||||
/* From i to end are simple clusters. */
|
/* From idx to end are simple clusters. */
|
||||||
while (buffer->idx < end && buffer->successful)
|
while (buffer->idx < end && buffer->successful)
|
||||||
decompose_current_character (&c, might_short_circuit);
|
decompose_current_character (&c, might_short_circuit);
|
||||||
|
|
||||||
if (buffer->idx == count || !buffer->successful)
|
if (buffer->idx == count || !buffer->successful)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
all_simple = false;
|
||||||
|
|
||||||
/* Find all the marks now. */
|
/* Find all the marks now. */
|
||||||
for (end = buffer->idx + 1; end < count; end++)
|
for (end = buffer->idx + 1; end < count; end++)
|
||||||
if (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&buffer->info[end])))
|
if (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK (_hb_glyph_info_get_general_category (&buffer->info[end])))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* idx to end is one non-simple cluster. */
|
||||||
decompose_multi_char_cluster (&c, end, always_short_circuit);
|
decompose_multi_char_cluster (&c, end, always_short_circuit);
|
||||||
}
|
}
|
||||||
while (buffer->idx < count && buffer->successful);
|
while (buffer->idx < count && buffer->successful);
|
||||||
buffer->swap_buffers ();
|
buffer->swap_buffers ();
|
||||||
|
|
||||||
|
|
||||||
/* Second round, reorder (inplace) */
|
/* Second round, reorder (inplace) */
|
||||||
|
if (!all_simple)
|
||||||
|
{
|
||||||
count = buffer->len;
|
count = buffer->len;
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -376,6 +380,7 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan,
|
||||||
|
|
||||||
i = end;
|
i = end;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_CGJ)
|
if (buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_CGJ)
|
||||||
{
|
{
|
||||||
/* For all CGJ, check if it prevented any reordering at all.
|
/* For all CGJ, check if it prevented any reordering at all.
|
||||||
|
@ -393,8 +398,9 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan,
|
||||||
|
|
||||||
/* Third round, recompose */
|
/* Third round, recompose */
|
||||||
|
|
||||||
if (mode == HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS ||
|
if (!all_simple &&
|
||||||
mode == HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT)
|
(mode == HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS ||
|
||||||
|
mode == HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT))
|
||||||
{
|
{
|
||||||
/* As noted in the comment earlier, we don't try to combine
|
/* As noted in the comment earlier, we don't try to combine
|
||||||
* ccc=0 chars with their previous Starter. */
|
* ccc=0 chars with their previous Starter. */
|
||||||
|
|
Loading…
Reference in New Issue