Move apply down into subtables accel

This commit is contained in:
Behdad Esfahbod 2018-10-10 11:54:48 -04:00
parent 78c09bf213
commit e78549edfb
2 changed files with 12 additions and 15 deletions

View File

@ -2632,7 +2632,15 @@ struct hb_ot_layout_lookup_accelerator_t
inline bool may_have (hb_codepoint_t g) const inline bool may_have (hb_codepoint_t g) const
{ return digest.may_have (g); } { return digest.may_have (g); }
public: inline bool apply (hb_ot_apply_context_t *c) const
{
for (unsigned int i = 0; i < subtables.len; i++)
if (subtables[i].apply (c))
return true;
return false;
}
private:
hb_set_digest_t digest; hb_set_digest_t digest;
hb_get_subtables_context_t::array_t subtables; hb_get_subtables_context_t::array_t subtables;
}; };

View File

@ -1118,7 +1118,6 @@ apply_forward (OT::hb_ot_apply_context_t *c,
{ {
bool ret = false; bool ret = false;
hb_buffer_t *buffer = c->buffer; hb_buffer_t *buffer = c->buffer;
const OT::hb_get_subtables_context_t::array_t &subtables = accel.subtables;
while (buffer->idx < buffer->len && buffer->successful) while (buffer->idx < buffer->len && buffer->successful)
{ {
bool applied = false; bool applied = false;
@ -1126,12 +1125,7 @@ apply_forward (OT::hb_ot_apply_context_t *c,
(buffer->cur().mask & c->lookup_mask) && (buffer->cur().mask & c->lookup_mask) &&
c->check_glyph_property (&buffer->cur(), c->lookup_props)) c->check_glyph_property (&buffer->cur(), c->lookup_props))
{ {
for (unsigned int i = 0; i < subtables.len; i++) applied = accel.apply (c);
if (subtables[i].apply (c))
{
applied = true;
break;
}
} }
if (applied) if (applied)
@ -1148,19 +1142,14 @@ apply_backward (OT::hb_ot_apply_context_t *c,
{ {
bool ret = false; bool ret = false;
hb_buffer_t *buffer = c->buffer; hb_buffer_t *buffer = c->buffer;
const OT::hb_get_subtables_context_t::array_t &subtables = accel.subtables;
do do
{ {
if (accel.may_have (buffer->cur().codepoint) && if (accel.may_have (buffer->cur().codepoint) &&
(buffer->cur().mask & c->lookup_mask) && (buffer->cur().mask & c->lookup_mask) &&
c->check_glyph_property (&buffer->cur(), c->lookup_props)) c->check_glyph_property (&buffer->cur(), c->lookup_props))
{ {
for (unsigned int i = 0; i < subtables.len; i++) if (accel.apply (c))
if (subtables[i].apply (c)) ret = true;
{
ret = true;
break;
}
} }
/* The reverse lookup doesn't "advance" cursor (for good reason). */ /* The reverse lookup doesn't "advance" cursor (for good reason). */
buffer->idx--; buffer->idx--;