Simplify chaining

This commit is contained in:
Behdad Esfahbod 2010-05-05 01:37:58 -04:00
parent 1911b9d21b
commit 4169710911
1 changed files with 25 additions and 36 deletions

View File

@ -258,20 +258,15 @@ static inline bool context_lookup (hb_apply_context_t *context,
const LookupRecord lookupRecord[], const LookupRecord lookupRecord[],
ContextLookupContext &lookup_context) ContextLookupContext &lookup_context)
{ {
unsigned int new_context_length; hb_apply_context_t new_context = *context;
if (!match_input (context, return match_input (context,
inputCount, input, inputCount, input,
lookup_context.funcs.match, lookup_context.match_data, lookup_context.funcs.match, lookup_context.match_data,
&new_context_length)) return false; &new_context.context_length)
unsigned int old_context_length; && apply_lookup (&new_context,
old_context_length = context->context_length; inputCount,
context->context_length = new_context_length; lookupCount, lookupRecord,
bool ret = apply_lookup (context, lookup_context.funcs.apply);
inputCount,
lookupCount, lookupRecord,
lookup_context.funcs.apply);
context->context_length = old_context_length;
return ret;
} }
struct Rule struct Rule
@ -529,28 +524,22 @@ static inline bool chain_context_lookup (hb_apply_context_t *context,
inputCount + lookaheadCount > context->context_length)) inputCount + lookaheadCount > context->context_length))
return false; return false;
unsigned int offset; hb_apply_context_t new_context = *context;
if (!(match_backtrack (context, return match_backtrack (context,
backtrackCount, backtrack, backtrackCount, backtrack,
lookup_context.funcs.match, lookup_context.match_data[0]) && lookup_context.funcs.match, lookup_context.match_data[0])
match_input (context, && match_input (context,
inputCount, input, inputCount, input,
lookup_context.funcs.match, lookup_context.match_data[1], lookup_context.funcs.match, lookup_context.match_data[1],
&offset) && &new_context.context_length)
match_lookahead (context, && match_lookahead (context,
lookaheadCount, lookahead, lookaheadCount, lookahead,
lookup_context.funcs.match, lookup_context.match_data[2], lookup_context.funcs.match, lookup_context.match_data[2],
offset))) return false; new_context.context_length)
&& apply_lookup (&new_context,
unsigned int old_context_length; inputCount,
old_context_length = context->context_length; lookupCount, lookupRecord,
context->context_length = offset; lookup_context.funcs.apply);
bool ret = apply_lookup (context,
inputCount,
lookupCount, lookupRecord,
lookup_context.funcs.apply);
context->context_length = old_context_length;
return ret;
} }
struct ChainRule struct ChainRule