oxc/crates/oxc_parser
overlookmotel 383f5b3081
perf(parser): consume multi-line comments faster (#2377)
Consume multi-line comments faster.

* Initially search for `*/`, `\r`, `\n` or `0xE2` (first byte of
irregular line breaks).
* Once a line break is found, switch to faster search which only looks
for `*/`, as it's not relevant whether there are more line breaks or
not.

Using `memchr` for the 2nd simpler search, as it's efficient for a
search with only one "needle".

Initializing `memchr::memmem::Finder` is fairly expensive, and tried
numerous ways to handle it. This is most performant way I could find.
Any ideas how to avoid re-creating it for each Lexer pass? (it can't be
a `static` as `Finder::new` is not a const function, and `lazy_static!`
is too costly)
2024-02-11 12:43:14 +08:00
..
examples chore(parser): add visitor example (#2271) 2024-02-02 17:08:00 +08:00
src perf(parser): consume multi-line comments faster (#2377) 2024-02-11 12:43:14 +08:00
Cargo.toml perf(parser): consume multi-line comments faster (#2377) 2024-02-11 12:43:14 +08:00