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

Function starts_with

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

This is faster than `[u8]::starts_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

97/// This is faster than `[u8]::starts_with` for small slices.
98/// See <https://github.com/apache/arrow-rs/issues/6107> for more details.
99fn starts_with(
100 haystack: &[u8],
101 needle: &[u8],
102 byte_eq_kernel: impl Fn((&u8, &u8)) -> bool,
103) -> bool {
104 if needle.len() > haystack.len() {
105 false
106 } else {
107 zip(haystack, needle).all(byte_eq_kernel)
108 }
109}
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 {

Callers 2

evaluateMethod · 0.70
evaluate_arrayMethod · 0.70

Calls 3

zipFunction · 0.85
allMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected