From 72a5ab948e8551fc83fe1de2a3f9eb094fa8f4e7 Mon Sep 17 00:00:00 2001 From: mxsm Date: Tue, 6 Jan 2026 07:49:50 +0000 Subject: [PATCH] =?UTF-8?q?[ISSUE=20#96]=E2=9C=A8Refine=20SIMD=20feature?= =?UTF-8?q?=20checks=20for=20string=20operations=20in=20CheetahString?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cheetah_string.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/cheetah_string.rs b/src/cheetah_string.rs index dc07874..536b13c 100644 --- a/src/cheetah_string.rs +++ b/src/cheetah_string.rs @@ -472,11 +472,11 @@ impl CheetahString { match pat.as_str_pattern() { StrPatternImpl::Char(c) => self.as_str().starts_with(c), StrPatternImpl::Str(s) => { - #[cfg(feature = "simd")] + #[cfg(all(feature = "simd", target_arch = "x86_64"))] { crate::simd::starts_with_bytes(self.as_bytes(), s.as_bytes()) } - #[cfg(not(feature = "simd"))] + #[cfg(not(all(feature = "simd", target_arch = "x86_64")))] { self.as_str().starts_with(s) } @@ -520,11 +520,11 @@ impl CheetahString { match pat.as_str_pattern() { StrPatternImpl::Char(c) => self.as_str().ends_with(c), StrPatternImpl::Str(s) => { - #[cfg(feature = "simd")] + #[cfg(all(feature = "simd", target_arch = "x86_64"))] { crate::simd::ends_with_bytes(self.as_bytes(), s.as_bytes()) } - #[cfg(not(feature = "simd"))] + #[cfg(not(all(feature = "simd", target_arch = "x86_64")))] { self.as_str().ends_with(s) } @@ -568,11 +568,11 @@ impl CheetahString { match pat.as_str_pattern() { StrPatternImpl::Char(c) => self.as_str().contains(c), StrPatternImpl::Str(s) => { - #[cfg(feature = "simd")] + #[cfg(all(feature = "simd", target_arch = "x86_64"))] { crate::simd::find_bytes(self.as_bytes(), s.as_bytes()).is_some() } - #[cfg(not(feature = "simd"))] + #[cfg(not(all(feature = "simd", target_arch = "x86_64")))] { self.as_str().contains(s) } @@ -613,11 +613,11 @@ impl CheetahString { #[inline] pub fn find>(&self, pat: P) -> Option { let pat = pat.as_ref(); - #[cfg(feature = "simd")] + #[cfg(all(feature = "simd", target_arch = "x86_64"))] { crate::simd::find_bytes(self.as_bytes(), pat.as_bytes()) } - #[cfg(not(feature = "simd"))] + #[cfg(not(all(feature = "simd", target_arch = "x86_64")))] { self.as_str().find(pat) } @@ -950,11 +950,11 @@ impl CheetahString { impl PartialEq for CheetahString { #[inline] fn eq(&self, other: &Self) -> bool { - #[cfg(feature = "simd")] + #[cfg(all(feature = "simd", target_arch = "x86_64"))] { crate::simd::eq_bytes(self.as_bytes(), other.as_bytes()) } - #[cfg(not(feature = "simd"))] + #[cfg(not(all(feature = "simd", target_arch = "x86_64")))] { self.as_str() == other.as_str() } @@ -964,11 +964,11 @@ impl PartialEq for CheetahString { impl PartialEq for CheetahString { #[inline] fn eq(&self, other: &str) -> bool { - #[cfg(feature = "simd")] + #[cfg(all(feature = "simd", target_arch = "x86_64"))] { crate::simd::eq_bytes(self.as_bytes(), other.as_bytes()) } - #[cfg(not(feature = "simd"))] + #[cfg(not(all(feature = "simd", target_arch = "x86_64")))] { self.as_str() == other } @@ -978,11 +978,11 @@ impl PartialEq for CheetahString { impl PartialEq for CheetahString { #[inline] fn eq(&self, other: &String) -> bool { - #[cfg(feature = "simd")] + #[cfg(all(feature = "simd", target_arch = "x86_64"))] { crate::simd::eq_bytes(self.as_bytes(), other.as_bytes()) } - #[cfg(not(feature = "simd"))] + #[cfg(not(all(feature = "simd", target_arch = "x86_64")))] { self.as_str() == other.as_str() }