oxc/crates/oxc_parser
overlookmotel 996a9d27eb
perf(parser): byte_search macro always unroll main loop (#2439)
Refactor `byte_search!` macro to move logic out of the main loop. This ensures the compiler unrolls the loop.

This speeds up lexing single-line comments by 20%-25% on the benchmarks which contain enough comments for the change to register. Presumably the loop wasn't unrolled previously.

The code required to do this is a little odd. It adds an extra `loop {}` which always exits on the first turn (so not really a useful loop), but is required to be able to use `break` to exit that "loop", making 2 different paths for (1) matching byte found and (2) `for` loop completed without finding any match.

This is only way I could find to produce this behavior without using a macro. Is there a more "normal" way to get the same logic?
2024-02-20 10:39:52 +08:00
..
examples chore(parser): add visitor example (#2271) 2024-02-02 17:08:00 +08:00
src perf(parser): byte_search macro always unroll main loop (#2439) 2024-02-20 10:39:52 +08:00
Cargo.toml perf(parser): consume multi-line comments faster (#2377) 2024-02-11 12:43:14 +08:00