We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It's not uncommon for a lexer state to be compiled to dozens of states. Currently we generate code like this:
match self.state { 0 -> ..., 1 -> ..., ... _ -> ..., }
For N states this means N-1 comparisons in the worst case to the take last branch.
Instead we should compile each state to a function, then put them all in an array:
static STATES: [fn(...) -> ...; N] = [...];
Then just do STATES[self.state](...);.
STATES[self.state](...);
The text was updated successfully, but these errors were encountered:
I implemented this in state_functions but cargo bench reports 5% regression in the Lua benchmark, and even worse in a micro benchmark.
state_functions
cargo bench
Sorry, something went wrong.
This is because the current code is compiled to a jump table. Closing.
No branches or pull requests
It's not uncommon for a lexer state to be compiled to dozens of states. Currently we generate code like this:
For N states this means N-1 comparisons in the worst case to the take last branch.
Instead we should compile each state to a function, then put them all in an array:
Then just do
STATES[self.state](...);
.The text was updated successfully, but these errors were encountered: