diff --git a/Objects/stringlib/fastsearch.h b/Objects/stringlib/fastsearch.h index 56a4467d35..a824a5a5d4 100644 --- a/Objects/stringlib/fastsearch.h +++ b/Objects/stringlib/fastsearch.h @@ -194,8 +194,7 @@ FASTSEARCH(const STRINGLIB_CHAR* s, Py_ssize_t n, } } - mlast = m - 1; - skip = mlast - 1; + mlast = skip = m - 1; mask = 0; if (mode != FAST_RSEARCH) { @@ -235,10 +234,13 @@ FASTSEARCH(const STRINGLIB_CHAR* s, Py_ssize_t n, i = i + m; else i = i + skip; - } else { + } + else { /* skip: check if next character is part of pattern */ if (!STRINGLIB_BLOOM(mask, ss[i+1])) i = i + m; + else if (!STRINGLIB_BLOOM(mask, ss[i])) + i = i + m-1; } } } else { /* FAST_RSEARCH */