[otlayout] Simplify ligate_input()

Shouldn't change behavior at all, but is faster / more robust.
This commit is contained in:
Behdad Esfahbod 2013-10-17 13:49:51 +02:00
parent 6b2abdcd20
commit e714fe6d6a
2 changed files with 14 additions and 19 deletions

View File

@ -663,28 +663,26 @@ struct Ligature
unsigned int count = component.len;
if (unlikely (count < 1)) return TRACE_RETURN (false);
unsigned int end_offset = 0;
bool is_mark_ligature = false;
unsigned int total_component_count = 0;
unsigned int match_length = 0;
unsigned int match_positions[MAX_CONTEXT_LENGTH];
if (likely (!match_input (c, count,
&component[1],
match_glyph,
NULL,
&end_offset,
NULL,
&match_length,
match_positions,
&is_mark_ligature,
&total_component_count)))
return TRACE_RETURN (false);
/* Deal, we are forming the ligature. */
c->buffer->merge_clusters (c->buffer->idx, c->buffer->idx + end_offset);
ligate_input (c,
count,
&component[1],
match_glyph,
NULL,
match_positions,
match_length,
ligGlyph,
is_mark_ligature,
total_component_count);

View File

@ -832,17 +832,16 @@ static inline bool match_input (hb_apply_context_t *c,
return TRACE_RETURN (true);
}
static inline void ligate_input (hb_apply_context_t *c,
unsigned int count, /* Including the first glyph (not matched) */
const USHORT input[], /* Array of input values--start with second glyph */
match_func_t match_func,
const void *match_data,
unsigned int count, /* Including the first glyph */
unsigned int match_positions[MAX_CONTEXT_LENGTH], /* Including the first glyph */
unsigned int match_length,
hb_codepoint_t lig_glyph,
bool is_mark_ligature,
unsigned int total_component_count)
{
hb_apply_context_t::skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, count - 1);
skippy_iter.set_match_func (match_func, match_data, input);
if (skippy_iter.has_no_chance ()) return;
TRACE_APPLY (NULL);
c->buffer->merge_clusters (c->buffer->idx, c->buffer->idx + match_length);
/*
* - If it *is* a mark ligature, we don't allocate a new ligature id, and leave
@ -888,9 +887,7 @@ static inline void ligate_input (hb_apply_context_t *c,
for (unsigned int i = 1; i < count; i++)
{
if (!skippy_iter.next ()) return;
while (c->buffer->idx < skippy_iter.idx)
while (c->buffer->idx < match_positions[i])
{
if (!is_mark_ligature) {
unsigned int new_lig_comp = components_so_far - last_num_components +