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

Function ends_with

arrow-string/src/predicate.rs:220–230  ·  view source on GitHub ↗

This is faster than `str::ends_with` for small strings. See for more details.

(haystack: &str, needle: &str, byte_eq_kernel: impl Fn((&u8, &u8)) -> bool)

Source from the content-addressed store, hash-verified

218/// This is faster than `str::ends_with` for small strings.
219/// See <https://github.com/apache/arrow-rs/issues/6107> for more details.
220fn ends_with(haystack: &str, needle: &str, byte_eq_kernel: impl Fn((&u8, &u8)) -> bool) -> bool {
221 if needle.len() > haystack.len() {
222 false
223 } else {
224 zip(
225 haystack.as_bytes().iter().rev(),
226 needle.as_bytes().iter().rev(),
227 )
228 .all(byte_eq_kernel)
229 }
230}
231
232fn equals_kernel((n, h): (&u8, &u8)) -> bool {
233 n == h

Callers 2

evaluateMethod · 0.70
evaluate_arrayMethod · 0.70

Calls 5

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

Tested by

no test coverage detected