Skip to content

Commit aa20494

Browse files
authored
perf(es/fast-lexer): Optimize memory layout of cursor (#10175)
**Description:** `pos` and `len` are frequently accessed
1 parent 1f70af8 commit aa20494

File tree

1 file changed

+3
-3
lines changed
  • crates/swc_ecma_fast_parser/src/lexer

1 file changed

+3
-3
lines changed

Diff for: crates/swc_ecma_fast_parser/src/lexer/cursor.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ use crate::util::unlikely;
1010
/// High-performance cursor for traversing input bytes
1111
#[repr(C)] // Ensure predictable memory layout for better cache behavior
1212
pub struct Cursor<'a> {
13-
/// Input source as bytes
14-
input: &'a [u8],
15-
1613
/// Current position in bytes
1714
pos: u32,
1815

1916
/// Length of the input in bytes
2017
len: u32,
18+
19+
/// Input source as bytes
20+
input: &'a [u8],
2121
}
2222

2323
impl<'a> Cursor<'a> {

0 commit comments

Comments
 (0)