refactor: remove unstable feature slice_as_chunks (#632)

This commit is contained in:
Sg 2023-07-26 19:21:35 +08:00 committed by GitHub
parent fbb8aa3338
commit 2203d08199
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 27 deletions

View file

@ -39,23 +39,24 @@ impl SkipWhitespace {
}
pub fn simd(&mut self, bytes: &[u8]) -> &Self {
let (chunks, remainder) = bytes.as_chunks::<ELEMENTS>();
let chunks = bytes.chunks(ELEMENTS);
for chunk in chunks {
self.check_chunk(chunk);
if self.found {
return self;
if chunk.len() == ELEMENTS {
self.check_chunk(chunk);
if self.found {
return self;
}
} else {
let remainder = chunk;
// Align the last chunk for avoiding the use of a scalar version
let mut chunk = [0; ELEMENTS];
let len = remainder.len();
chunk[..len].copy_from_slice(remainder);
self.check_chunk(&chunk);
}
}
if !remainder.is_empty() {
// Align the last chunk for avoiding the use of a scalar version
let mut chunk = [0; ELEMENTS];
let len = remainder.len();
chunk[..len].copy_from_slice(remainder);
self.check_chunk(&chunk);
}
self
}
@ -120,23 +121,22 @@ impl<'a> SkipMultilineComment<'a> {
}
pub fn simd(&mut self) -> &Self {
let (chunks, remainder) = self.remaining.as_chunks::<ELEMENTS>();
for chunk in chunks {
self.check(chunk, chunk.len());
if self.found {
return self;
for chunk in self.remaining.chunks(ELEMENTS) {
if chunk.len() == ELEMENTS {
self.check(chunk, chunk.len());
if self.found {
return self;
}
} else {
let remainder = chunk;
// Align the last chunk for avoiding the use of a scalar version
let mut chunk = [0; ELEMENTS];
let len = remainder.len();
chunk[..len].copy_from_slice(remainder);
self.check(&chunk, len);
}
}
if !remainder.is_empty() {
// Align the last chunk for avoiding the use of a scalar version
let mut chunk = [0; ELEMENTS];
let len = remainder.len();
chunk[..len].copy_from_slice(remainder);
self.check(&chunk, len);
}
self
}

View file

@ -62,7 +62,6 @@
#![allow(clippy::wildcard_imports)] // allow for use `oxc_ast::ast::*`
#![cfg_attr(not(target_arch = "wasm32"), feature(portable_simd))]
#![feature(slice_as_chunks)]
mod context;
mod cursor;