Repository navigation
Commit e8243dc
committed
perf: cut the lookahead scans in ComplexExpressionList
`ComplexExpressionList()` parses every function argument list, and its
lookaheads took 11% of parse CPU on `performance.sql`. The loop's
`LOOKAHEAD(2) ","` scanned through the choice behind the comma, so every
nested lookahead ran once in the scan and again when the choice was
entered. And JavaCC scanned a token of `Expression()` before entering the
default alternative of both choices, which a semantic lookahead on that
alternative avoids.
The loop now checks for a comma by token kind and the default
alternatives enter `Expression()` directly. `SimpleExpressionList()` gets
the same two changes. Parser CPU per parse drops from 33.5 ms to 29.8 ms
(-11.5%, three interleaved pairs), and `./gradlew jmh` from 39.31 to
32.06 ms/op.1 parent a075737 commit e8243dc
1 file changed
Lines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12783 | 12783 | | |
12784 | 12784 | | |
12785 | 12785 | | |
12786 | | - | |
| 12786 | + | |
12787 | 12787 | | |
12788 | 12788 | | |
12789 | 12789 | | |
12790 | | - | |
| 12790 | + | |
12791 | 12791 | | |
12792 | 12792 | | |
12793 | 12793 | | |
| |||
12835 | 12835 | | |
12836 | 12836 | | |
12837 | 12837 | | |
12838 | | - | |
| 12838 | + | |
| 12839 | + | |
12839 | 12840 | | |
12840 | 12841 | | |
12841 | 12842 | | |
12842 | 12843 | | |
12843 | 12844 | | |
12844 | 12845 | | |
12845 | | - | |
| 12846 | + | |
12846 | 12847 | | |
12847 | 12848 | | |
12848 | 12849 | | |
12849 | 12850 | | |
12850 | 12851 | | |
12851 | 12852 | | |
12852 | 12853 | | |
12853 | | - | |
| 12854 | + | |
12854 | 12855 | | |
12855 | 12856 | | |
12856 | 12857 | | |
| |||
0 commit comments