Skip to content

Commit 5b32695

Browse files
committed
Specialize search with memcmp when the haystack length equal needle length
1 parent 7aba3a2 commit 5b32695

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/x86.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,8 @@ impl<N: Needle> Avx2Searcher<N> {
416416
#[inline]
417417
#[target_feature(enable = "avx2")]
418418
pub unsafe fn inlined_search_in(&self, haystack: &[u8]) -> bool {
419-
if haystack.len() < self.needle.size() {
420-
return false;
419+
if haystack.len() <= self.needle.size() {
420+
return haystack == self.needle.as_bytes();
421421
}
422422

423423
self.avx2_search_in(haystack)

0 commit comments

Comments
 (0)