This is faster than `[u8]::starts_with` for small slices. See for more details.
(
haystack: &[u8],
needle: &[u8],
byte_eq_kernel: impl Fn((&u8, &u8)) -> bool,
)
| 97 | /// This is faster than `[u8]::starts_with` for small slices. |
| 98 | /// See <https://github.com/apache/arrow-rs/issues/6107> for more details. |
| 99 | fn starts_with( |
| 100 | haystack: &[u8], |
| 101 | needle: &[u8], |
| 102 | byte_eq_kernel: impl Fn((&u8, &u8)) -> bool, |
| 103 | ) -> bool { |
| 104 | if needle.len() > haystack.len() { |
| 105 | false |
| 106 | } else { |
| 107 | zip(haystack, needle).all(byte_eq_kernel) |
| 108 | } |
| 109 | } |
| 110 | /// This is faster than `[u8]::ends_with` for small slices. |
| 111 | /// See <https://github.com/apache/arrow-rs/issues/6107> for more details. |
| 112 | fn ends_with(haystack: &[u8], needle: &[u8], byte_eq_kernel: impl Fn((&u8, &u8)) -> bool) -> bool { |
no test coverage detected