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

Function starts_with

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

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)

Source from the content-addressed store, hash-verified

209/// This is faster than `str::starts_with` for small strings.
210/// See <https://github.com/apache/arrow-rs/issues/6107> for more details.
211fn 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.
220fn ends_with(haystack: &str, needle: &str, byte_eq_kernel: impl Fn((&u8, &u8)) -> bool) -> bool {

Callers 2

evaluateMethod · 0.70
evaluate_arrayMethod · 0.70

Calls 4

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

Tested by

no test coverage detected