Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tweak thresholds based on most recent comparison.
  • Loading branch information
sweeneyde committed Jul 16, 2021
commit 72143efaade208f684c1801daa00a9c502f82ceb
5 changes: 3 additions & 2 deletions Objects/stringlib/fastsearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -760,10 +760,11 @@ FASTSEARCH(const STRINGLIB_CHAR* s, Py_ssize_t n,
}

if (mode != FAST_RSEARCH) {
if (n < 3000 || (m < 100 && n < 30000) || m < 6) {
if (n < 2500 || (m < 100 && n < 30000) || m < 6) {
return STRINGLIB(default_find)(s, n, p, m, maxcount, mode);
}
else if (6 * m < n) {
else if ((m >> 2) * 3 > (n >> 2)) {
/* 33% threshold, but don't overflow. */
/* For larger problems where the needle isn't a huge
percentage of the size of the haystack, the relatively
expensive O(m) startup cost of the two-way algorithm
Expand Down