Skip to content

Commit f2b04f0

Browse files
committed
impl
1 parent a7541c3 commit f2b04f0

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Objects/stringlib/fastsearch.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,15 @@ FASTSEARCH(const STRINGLIB_CHAR* s, Py_ssize_t n,
795795
return STRINGLIB(count_char)(s, n, p[0], maxcount);
796796
}
797797
}
798+
else if (n == m) {
799+
/* use special case when both strings are of equal length */
800+
int res = memcmp(s, p, m * sizeof(STRINGLIB_CHAR));
801+
if (mode == FAST_COUNT){
802+
return res == 0 ? 1 : 0;
803+
} else {
804+
return res == 0 ? 0 : -1;
805+
}
806+
}
798807

799808
if (mode != FAST_RSEARCH) {
800809
if (n < 2500 || (m < 100 && n < 30000) || m < 6) {

0 commit comments

Comments
 (0)