Performance improvement: Lookup table for State.actions #14
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "optimize"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes https://github.com/lezer-parser/lezer/issues/42
This changes what this loop does—in the existing code, the action will be accepted (via
continue actions) if any matching action is found. In the new code, the function will return false as soon as any conflicting action is found.Given this distinction, I also don't think your assumption that the function will return the same for swapped
a/barguments is solid. It is probably possible to optimize that better than just calling it twice, though.@ -250,0 +262,4 @@}}return this.actionsMapCache[term.hash] ?? []}It'd be nice if you tried to use spacing consistent with the rest of the file (I see 3 styles for
for/ifin this function, and no spaces around the=below).ok reverted
@ -250,0 +262,4 @@}}return this.actionsMapCache[term.hash] ?? []}fixed
For what it's worth, this change didn't affect my generator output. Is it possible that this change wouldn't affect the overall algorithm?
This will only make a difference for states with multiple actions for a token (GLR) that happen to be mergeable, so it is likely this change doesn't affect most grammars.
I've merged
github.com/lezer-parser/generator@e5ad5d560band replaced the rest of this patch withgithub.com/lezer-parser/generator@4e5afa07c6. Could you take a look and see how well the optimization works for your grammar?It works great, down from 57s to 35s. Thanks so much
Pull request closed