You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Embed branch symbol sequences directly in the per-token selector
Previously the per-(rule, token) selector stored a list of branch
indexes that the parser then had to look up in $rules[$rule_id] on
every branch attempt. Store the branch symbol sequences themselves so
the hot loop can iterate candidate branches directly.
PHP arrays are copy-on-write, so sharing the same branch sequence
across selector entries for many tokens costs negligible extra memory.
The nullable_branches map shrinks to a bool marker since the parser
only uses it for existence checks.
Also cache the start rule id on the grammar so parse() skips its
array_search() across rule_names on every call.
End-to-end parser benchmark:
Before: ~29,800 QPS (avg) After: ~31,700 QPS (+6%).
0 commit comments