Skip to content

Commit a168c22

Browse files
committed
simplify
1 parent 48168d0 commit a168c22

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Diff for: portable/src/implementation/fallback.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,17 @@ impl Utf8ValidatorImp {
6969
return;
7070
}
7171
};
72-
let rem_input = input.len() - e.valid_up_to() - 1;
73-
for i in 0..rem_input.min(self.expected_cont_bytes as usize) {
74-
if input[e.valid_up_to() + i + 1] & 0b1100_0000 != 0b1000_0000 {
72+
let rem_input = &input[e.valid_up_to() + 1..];
73+
let rem_input = &rem_input[0..rem_input.len().min(self.expected_cont_bytes as usize)];
74+
for b in rem_input {
75+
if b & 0b1100_0000 != 0b1000_0000 {
7576
// not a continuation byte
7677
self.err = true;
7778
return;
7879
}
7980
self.expected_cont_bytes -= 1;
8081
}
81-
debug_assert!(self.expected_cont_bytes != 0); // otherwise from_utf8 would not have errored
82+
debug_assert!(self.expected_cont_bytes > 0); // otherwise from_utf8 would not have errored
8283
}
8384
}
8485

0 commit comments

Comments
 (0)