mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
refactor(lexer): #[inline(always)] on line_break_in (#28650)
Part of effort to move to runtime CPU feature detection. Fixes codegen drift from on earlier step in this stack. Before the migration, `line_break_in` was inlined everywhere, and the `line_terminator_after` it wraps was called out of line. Since `cpu_versions!` was applied in C11, it was the other way round. Copies of `line_break_in` were called out of line from Level 2 (`gt_run_split`, `type_args_at`), with `line_terminator_after` inlined into them. `line_break_in` only wraps `line_terminator_after`, so it gets `#[inline(always)]` instead of `cpu_versions!`. It keeps `cpu`, because `line_terminator_after` is versioned. Its doc comment moves above its attribute, where it was before `cpu_versions!` needed to be the first attribute. Codegen: restores the original shape in all builds. `line_break_in` is inlined again, and `line_terminator_after` is called out of line again.
This commit is contained in:
1 parent
2839e6e90f
commit
7c6cfd3152
1 file changed
+1
-2
@@ -74,9 +74,8 @@ pub(super) fn line_terminator_after(src: &[u8], n: usize, mut i: usize, _cpu: im
|
||||
n
|
||||
}
|
||||
|
||||
#[apply(cpu_versions)]
|
||||
#[inline]
|
||||
/// Does src[a..b] hold a line terminator (LF, CR, or the 3-byte LS or PS)?
|
||||
#[inline(always)]
|
||||
pub(super) fn line_break_in(src: &[u8], a: usize, b: usize, cpu: impl Cpu) -> bool {
|
||||
line_terminator_after(src, b, a, cpu) < b
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user