This is faster than `[u8]::ends_with` for small slices. See for more details.
(haystack: &[u8], needle: &[u8], byte_eq_kernel: impl Fn((&u8, &u8)) -> bool)
| 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 { |
| 113 | if needle.len() > haystack.len() { |
| 114 | false |
| 115 | } else { |
| 116 | zip(haystack.iter().rev(), needle.iter().rev()).all(byte_eq_kernel) |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | fn equals_kernel((n, h): (&u8, &u8)) -> bool { |
| 121 | n == h |