From b310c28a0b7be07a2e0f3f571a0e3b3531cae1e1 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Sun, 9 Nov 2025 16:45:48 +0000 Subject: [PATCH] perf(lexer): inline `handle_byte` into `read_next_token` (#15520) Preparatory step for #15513. That PR adds a 2nd callsite for `handle_byte`. Mark it as `#[inline(always)]` to make sure it gets inlined in both places. This was originally part of #15513, but have split it out into a separate PR so that Codspeed's results on #15513 measure the actual substantive change in isolation - to check that change is having the effect I think it is, and that the gain wasn't actually coming from adding `#[inline(always)]` here. This PR has no effect on performance, so the gain *is* in #15513. --- crates/oxc_parser/src/lexer/byte_handlers.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/oxc_parser/src/lexer/byte_handlers.rs b/crates/oxc_parser/src/lexer/byte_handlers.rs index 901806bc7ad19..fa88842794504 100644 --- a/crates/oxc_parser/src/lexer/byte_handlers.rs +++ b/crates/oxc_parser/src/lexer/byte_handlers.rs @@ -12,6 +12,9 @@ impl Lexer<'_> { /// * Lexer must not be at end of file. /// * `byte` must be next byte of source code, corresponding to current position of `lexer.source`. /// * Only `BYTE_HANDLERS` for ASCII characters may use the `ascii_byte_handler!()` macro. + // `#[inline(always)]` to ensure is inlined into `read_next_token` + #[expect(clippy::inline_always)] + #[inline(always)] pub(super) unsafe fn handle_byte(&mut self, byte: u8) -> Kind { // SAFETY: Caller guarantees to uphold safety invariants unsafe { BYTE_HANDLERS[byte as usize](self) }