mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-15 09:44:46 +00:00
[aat] Simplify complex condition
Based on https://github.com/RazrFalcon/rustybuzz/discussions/79#discussioncomment-6960324
This commit is contained in:
parent
17ee3cd7f4
commit
978918c32a
1 changed files with 34 additions and 36 deletions
|
@ -851,43 +851,41 @@ struct StateTableDriver
|
|||
*
|
||||
* https://github.com/harfbuzz/harfbuzz/issues/2860
|
||||
*/
|
||||
const EntryT *wouldbe_entry;
|
||||
bool safe_to_break =
|
||||
/* 1. */
|
||||
!c->is_actionable (this, entry)
|
||||
&&
|
||||
/* 2. */
|
||||
(
|
||||
/* 2a. */
|
||||
state == StateTableT::STATE_START_OF_TEXT
|
||||
||
|
||||
/* 2b. */
|
||||
(
|
||||
(entry.flags & context_t::DontAdvance) &&
|
||||
next_state == StateTableT::STATE_START_OF_TEXT
|
||||
)
|
||||
||
|
||||
/* 2c. */
|
||||
(
|
||||
wouldbe_entry = &machine.get_entry (StateTableT::STATE_START_OF_TEXT, klass)
|
||||
,
|
||||
/* 2c'. */
|
||||
!c->is_actionable (this, *wouldbe_entry)
|
||||
&&
|
||||
/* 2c". */
|
||||
(
|
||||
next_state == machine.new_state (wouldbe_entry->newState)
|
||||
&&
|
||||
(entry.flags & context_t::DontAdvance) == (wouldbe_entry->flags & context_t::DontAdvance)
|
||||
)
|
||||
)
|
||||
)
|
||||
&&
|
||||
/* 3. */
|
||||
!c->is_actionable (this, machine.get_entry (state, StateTableT::CLASS_END_OF_TEXT))
|
||||
;
|
||||
|
||||
if (!safe_to_break && buffer->backtrack_len () && buffer->idx < buffer->len)
|
||||
const auto is_safe_to_break_extra = [&]()
|
||||
{
|
||||
/* 2c. */
|
||||
const auto wouldbe_entry = machine.get_entry(StateTableT::STATE_START_OF_TEXT, klass);
|
||||
|
||||
/* 2c'. */
|
||||
if (c->is_actionable (this, wouldbe_entry))
|
||||
return false;
|
||||
|
||||
/* 2c". */
|
||||
return next_state == machine.new_state(wouldbe_entry.newState)
|
||||
&& (entry.flags & context_t::DontAdvance) == (wouldbe_entry.flags & context_t::DontAdvance);
|
||||
};
|
||||
|
||||
const auto is_safe_to_break = [&]()
|
||||
{
|
||||
/* 1. */
|
||||
if (c->is_actionable (this, entry))
|
||||
return false;
|
||||
|
||||
/* 2. */
|
||||
// This one is meh, I know...
|
||||
const auto ok =
|
||||
state == StateTableT::STATE_START_OF_TEXT
|
||||
|| ((entry.flags & context_t::DontAdvance) && next_state == StateTableT::STATE_START_OF_TEXT)
|
||||
|| is_safe_to_break_extra();
|
||||
if (!ok)
|
||||
return false;
|
||||
|
||||
/* 3. */
|
||||
return !c->is_actionable (this, machine.get_entry (state, StateTableT::CLASS_END_OF_TEXT));
|
||||
};
|
||||
|
||||
if (!is_safe_to_break () && buffer->backtrack_len () && buffer->idx < buffer->len)
|
||||
buffer->unsafe_to_break_from_outbuffer (buffer->backtrack_len () - 1, buffer->idx + 1);
|
||||
|
||||
c->transition (this, entry);
|
||||
|
|
Loading…
Add table
Reference in a new issue