Skip to content

Commit 29418f0

Browse files
committed
CLEAN UP Scanner.scan EVEN MORE
The `scan` code was rather irregular, due to some quirks around when to `peek`, when to `next`, etc. I'm guessing out of a misguided desire to save perf. The realization is that peeking 1 or 2 chars have the same perf, likewise for `next`ing 1 or 2 chars (well, in this diff, `next`ing 2 or 3 times are slightly more expensive but that's trivially fixable). Once we see that, we can just freely throw around the right amount of `peek` and `next` without needing to share some `next` code paths with some character lookahead and not with others. Perf is actually better now! Screenshot in PR. Also, much more readable. Previously, every time I check the `scan` code I needed to wrangle about which char I’m looking at and which char I’m looking at next, because of various imperative `next` calls here and there. No more!
1 parent dd80274 commit 29418f0

File tree

1 file changed

+172
-217
lines changed

1 file changed

+172
-217
lines changed

0 commit comments

Comments
 (0)