Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
template: add ASCII fast path for lexer.next
lexer.next is a hot function, as demonstrated by profiling. Most programs will consist of ASCII characters only, which we can optimize for. Ideally DecodeRuneInString would be inlined here and this wouldn't be a problem at all, but that won't be the case until golang/go#31666 is resolved. name old time/op new time/op delta Parse/lorem_ipsum-4 733ns ± 2% 733ns ± 2% ~ (p=0.933 n=8+8) Parse/short-4 16.6µs ± 1% 15.5µs ± 2% -6.75% (p=0.000 n=8+8) Parse/medium-4 40.1µs ± 1% 38.7µs ± 1% -3.51% (p=0.000 n=8+8) Parse/long-4 123µs ± 1% 115µs ± 1% -5.86% (p=0.001 n=7+7) Parse/very-long-4 416µs ± 1% 396µs ± 1% -4.70% (p=0.000 n=8+8) name old alloc/op new alloc/op delta Parse/lorem_ipsum-4 1.16kB ± 0% 1.16kB ± 0% ~ (all equal) Parse/short-4 5.42kB ± 0% 5.42kB ± 0% ~ (all equal) Parse/medium-4 12.6kB ± 0% 12.6kB ± 0% ~ (all equal) Parse/long-4 35.3kB ± 0% 35.3kB ± 0% ~ (all equal) Parse/very-long-4 113kB ± 0% 113kB ± 0% ~ (all equal) name old allocs/op new allocs/op delta Parse/lorem_ipsum-4 10.0 ± 0% 10.0 ± 0% ~ (all equal) Parse/short-4 107 ± 0% 107 ± 0% ~ (all equal) Parse/medium-4 296 ± 0% 296 ± 0% ~ (all equal) Parse/long-4 777 ± 0% 777 ± 0% ~ (all equal) Parse/very-long-4 2.61k ± 0% 2.61k ± 0% ~ (all equal)
- Loading branch information