mirror of
https://github.com/danbulant/oxc
synced 2026-05-21 13:18:59 +00:00
refactor(lexer): avoid copying of self in SIMD functions (#104)
This commit is contained in:
parent
91c01633d6
commit
dcfdce5bb7
2 changed files with 6 additions and 4 deletions
|
|
@ -483,7 +483,8 @@ impl<'a> Lexer<'a> {
|
|||
}
|
||||
|
||||
let remaining = self.remaining().as_bytes();
|
||||
let state = SkipWhitespace::new(self.current.token.is_on_new_line).simd(remaining);
|
||||
let mut state = SkipWhitespace::new(self.current.token.is_on_new_line);
|
||||
state.simd(remaining);
|
||||
|
||||
// SAFETY: offset is computed to the boundary
|
||||
self.current.chars =
|
||||
|
|
@ -512,7 +513,8 @@ impl<'a> Lexer<'a> {
|
|||
fn skip_multi_line_comment(&mut self) -> Kind {
|
||||
let remaining = self.remaining().as_bytes();
|
||||
let newline = self.current.token.is_on_new_line;
|
||||
let state = SkipMultilineComment::new(newline, remaining).simd();
|
||||
let mut state = SkipMultilineComment::new(newline, remaining);
|
||||
state.simd();
|
||||
|
||||
// SAFETY: offset is computed to the boundary
|
||||
self.current.chars =
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ impl SkipWhitespace {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn simd(mut self, bytes: &[u8]) -> Self {
|
||||
pub fn simd(&mut self, bytes: &[u8]) -> &Self {
|
||||
let (chunks, remainder) = bytes.as_chunks::<ELEMENTS>();
|
||||
|
||||
for chunk in chunks {
|
||||
|
|
@ -119,7 +119,7 @@ impl<'a> SkipMultilineComment<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn simd(mut self) -> Self {
|
||||
pub fn simd(&mut self) -> &Self {
|
||||
let (chunks, remainder) = self.remaining.as_chunks::<ELEMENTS>();
|
||||
|
||||
for chunk in chunks {
|
||||
|
|
|
|||
Loading…
Reference in a new issue