forked from haskell/alex
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve the performance by ~30% for lexers that don't use predicates
By specialising slightly for the case where left and right contexts are not used we can simplify the processing of accept actions in alex_scan_tkn. When we have left or right contexts we end up with chains of AlexAcc values and we have to do a traversal of these chains. When there are no left or right contexts then these chains are always length 1 which makes the traversal non-recursive. This change improves the performance singnificantly, (presumably because by being non-recursive ghc can inline and transform further). The 30% improvement measurment was from a lexer for .cabal files, but I don't think there is anything special about that example so would expect similar improvements for other lexers that don't use contexts. The change is only implemented for the -g case, but that's fine since that's what you'd use if you care about performance, and whether it'd be an improvement for other compilers is anyone's guess.
- Loading branch information
Showing
4 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters