This is faster than `str::starts_with` for small strings. See for more details.
(haystack: &str, needle: &str, byte_eq_kernel: impl Fn((&u8, &u8)) -> bool)
| 209 | /// This is faster than `str::starts_with` for small strings. |
| 210 | /// See <https://github.com/apache/arrow-rs/issues/6107> for more details. |
| 211 | fn starts_with(haystack: &str, needle: &str, byte_eq_kernel: impl Fn((&u8, &u8)) -> bool) -> bool { |
| 212 | if needle.len() > haystack.len() { |
| 213 | false |
| 214 | } else { |
| 215 | zip(haystack.as_bytes(), needle.as_bytes()).all(byte_eq_kernel) |
| 216 | } |
| 217 | } |
| 218 | /// This is faster than `str::ends_with` for small strings. |
| 219 | /// See <https://github.com/apache/arrow-rs/issues/6107> for more details. |
| 220 | fn ends_with(haystack: &str, needle: &str, byte_eq_kernel: impl Fn((&u8, &u8)) -> bool) -> bool { |