Skip to content

Commit 011d95b

Browse files
committed
Neon fast path for str::contains
1 parent fffc4fc commit 011d95b

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

library/core/src/str/pattern.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,8 @@ impl<'b> Pattern for &'b str {
997997

998998
#[cfg(any(
999999
all(target_arch = "x86_64", target_feature = "sse2"),
1000-
all(target_arch = "loongarch64", target_feature = "lsx")
1000+
all(target_arch = "loongarch64", target_feature = "lsx"),
1001+
all(target_arch = "aarch64", target_feature = "neon")
10011002
))]
10021003
if self.len() <= 32 {
10031004
if let Some(result) = simd_contains(self, haystack) {
@@ -1782,7 +1783,8 @@ impl TwoWayStrategy for RejectAndMatch {
17821783
/// [0]: http://0x80.pl/articles/simd-strfind.html#sse-avx2
17831784
#[cfg(any(
17841785
all(target_arch = "x86_64", target_feature = "sse2"),
1785-
all(target_arch = "loongarch64", target_feature = "lsx")
1786+
all(target_arch = "loongarch64", target_feature = "lsx"),
1787+
all(target_arch = "aarch64", target_feature = "neon")
17861788
))]
17871789
#[inline]
17881790
fn simd_contains(needle: &str, haystack: &str) -> Option<bool> {
@@ -1917,7 +1919,8 @@ fn simd_contains(needle: &str, haystack: &str) -> Option<bool> {
19171919
/// Both slices must have the same length.
19181920
#[cfg(any(
19191921
all(target_arch = "x86_64", target_feature = "sse2"),
1920-
all(target_arch = "loongarch64", target_feature = "lsx")
1922+
all(target_arch = "loongarch64", target_feature = "lsx"),
1923+
all(target_arch = "aarch64", target_feature = "neon")
19211924
))]
19221925
#[inline]
19231926
unsafe fn small_slice_eq(x: &[u8], y: &[u8]) -> bool {

0 commit comments

Comments
 (0)