MCPcopy Create free account
hub / github.com/apache/arrow-rs / ends_with

Function ends_with

arrow-string/src/binary_predicate.rs:112–118  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

110/// This is faster than `[u8]::ends_with` for small slices.
111/// See <https://github.com/apache/arrow-rs/issues/6107> for more details.
112fn 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
120fn equals_kernel((n, h): (&u8, &u8)) -> bool {
121 n == h

Callers 2

evaluateMethod · 0.70
evaluate_arrayMethod · 0.70

Calls 4

zipFunction · 0.85
allMethod · 0.80
lenMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected