From 8820bb235b1f63e4d93c8a2f5c08b44d89e06b78 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 14 Feb 2013 07:41:03 -0500 Subject: [PATCH] [OTLayout] Port apply_lookup to skippy_iter --- src/hb-ot-layout-gsubgpos-private.hh | 50 +++++++++++++++++++--------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index 53be8f8ca..61814ad84 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -839,19 +839,35 @@ static inline bool apply_lookup (hb_apply_context_t *c, * and we jump out of it. Not entirely disastrous. So we don't check * for reverse lookup here. */ - for (unsigned int i = 0; i < count; /* NOP */) + unsigned int i = 0; + if (lookupCount && 0 == lookupRecord->sequenceIndex) { - if (unlikely (c->buffer->idx == end)) - return TRACE_RETURN (true); + unsigned int old_pos = c->buffer->idx; - if (i) - while (c->should_skip_current_glyph ()) - { - /* No lookup applied for this index */ - c->buffer->next_glyph (); - if (unlikely (c->buffer->idx == end)) - return TRACE_RETURN (true); - } + /* Apply a lookup */ + bool done = c->recurse (lookupRecord->lookupListIndex); + + lookupRecord++; + lookupCount--; + /* Err, this is wrong if the lookup jumped over some glyphs */ + i += c->buffer->idx - old_pos; + + if (!done) + goto not_applied; + } + else + { + not_applied: + /* No lookup applied for this index */ + c->buffer->next_glyph (); + i++; + } + hb_apply_context_t::skipping_forward_iterator_t skippy_iter (c, c->buffer->idx - 1, count - i); + while (i < count) + { + if (!skippy_iter.next ()) return TRACE_RETURN (true); + while (c->buffer->idx < skippy_iter.idx) + c->buffer->next_glyph (); if (lookupCount && i == lookupRecord->sequenceIndex) { @@ -864,15 +880,19 @@ static inline bool apply_lookup (hb_apply_context_t *c, lookupCount--; /* Err, this is wrong if the lookup jumped over some glyphs */ i += c->buffer->idx - old_pos; - if (unlikely (c->buffer->idx == end)) - return TRACE_RETURN (true); if (!done) - goto not_applied; + goto not_applied2; + else + { + /* Reinitialize iterator. */ + hb_apply_context_t::skipping_forward_iterator_t tmp (c, c->buffer->idx - 1, count - i); + skippy_iter = tmp; + } } else { - not_applied: + not_applied2: /* No lookup applied for this index */ c->buffer->next_glyph (); i++;