Skip to content

Commit ce74394

Browse files
committed
simplify
1 parent cbed922 commit ce74394

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

portable/src/implementation/simd.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -921,17 +921,15 @@ impl basic::imp::ChunkedUtf8Validator for ChunkedUtf8ValidatorImp {
921921
mut self,
922922
remaining_input: core::option::Option<&[u8]>,
923923
) -> core::result::Result<(), basic::Utf8Error> {
924-
if let Some(mut remaining_input) = remaining_input {
924+
if let Some(remaining_input) = remaining_input {
925925
if !remaining_input.is_empty() {
926-
let len = remaining_input.len();
927-
let chunks_lim = len - (len % SIMD_CHUNK_SIZE);
928-
if chunks_lim > 0 {
929-
self.update_from_chunks(&remaining_input[..chunks_lim]);
926+
let mut chunks = remaining_input.chunks_exact(SIMD_CHUNK_SIZE);
927+
for chunk in &mut chunks {
928+
let input = SimdInput::new(chunk);
929+
self.algorithm.check_utf8(&input);
930930
}
931-
let rem = len - chunks_lim;
932-
if rem > 0 {
933-
remaining_input = &remaining_input[chunks_lim..];
934-
let simd_input = SimdInput::new_partial(remaining_input);
931+
if !chunks.remainder().is_empty() {
932+
let simd_input = SimdInput::new_partial(chunks.remainder());
935933
self.algorithm.check_utf8(&simd_input);
936934
}
937935
}

0 commit comments

Comments
 (0)