Closed tjvr closed 6 years ago
Cool 👍
I'm torn on this--it seems like adding a bunch of complexity just to game a particular benchmark :confused:
Is this as fast if we use [0]
rather than charCodeAt(0)
?
@tjvr
just to game a particular benchmark
I'm not sure it's just this benchmark. A lot of languages have single-character operators, and this speeds up lexing those a lot. A lot of languages also have multi-character operators, and we might want to think about speeding those up too—but since single characters result in the most dense token stream (and thus the highest potential for slowness), a fast case for single characters might be worth it.
charCodeAt() is unresonably fast. This makes the JSON benchmark ~50% faster.
Note we can only do this for single characters at the top of the lexer definition. :-)