Create subslice as that leads to a smaller code size.

This commit is contained in:
Hans Kratz 2021-11-04 17:03:13 +01:00
parent 2d9f0e2c50
commit a5b25a2cfa

View File

@ -153,14 +153,15 @@ impl<'a> StringReader<'a> {
match core::slice::memchr::memchr(0xE2, &bytes) {
Some(idx) => {
// bytes are valid UTF-8 -> E2 must be followed by two bytes
match bytes[idx + 1] {
let ch = &bytes[idx..idx + 3];
match ch[1] {
0x80 => {
if (0xAA..=0xAE).contains(&bytes[idx + 2]) {
if (0xAA..=0xAE).contains(&ch[2]) {
break true;
}
}
0x81 => {
if (0xA6..=0xA9).contains(&bytes[idx + 2]) {
if (0xA6..=0xA9).contains(&ch[2]) {
break true;
}
}