diff --git a/Objects/stringobject.c b/Objects/stringobject.c index c4a6a705704..ded1907fcaa 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -767,10 +767,6 @@ PyString_AsStringAndSize(register PyObject *obj, /* -------------------------------------------------------------------- */ /* stringlib components */ -#define USE_FAST - -#ifdef USE_FAST - #define STRINGLIB_CHAR char #define STRINGLIB_NEW PyString_FromStringAndSize #define STRINGLIB_EMPTY nullstring @@ -778,8 +774,6 @@ PyString_AsStringAndSize(register PyObject *obj, #include "stringlib/fastsearch.h" #include "stringlib/partition.h" -#endif - /* -------------------------------------------------------------------- */ /* Methods */ @@ -1054,13 +1048,7 @@ string_contains(PyObject *a, PyObject *el) char *s = PyString_AS_STRING(a); const char *sub = PyString_AS_STRING(el); Py_ssize_t len_sub = PyString_GET_SIZE(el); -#ifdef USE_FAST Py_ssize_t pos; -#else - char *last; - Py_ssize_t shortsub; - char firstchar, lastchar; -#endif if (!PyString_CheckExact(el)) { #ifdef Py_USING_UNICODE @@ -1077,35 +1065,12 @@ string_contains(PyObject *a, PyObject *el) if (len_sub == 0) return 1; -#ifdef USE_FAST pos = fastsearch( s, PyString_GET_SIZE(a), sub, len_sub, FAST_SEARCH ); + return (pos != -1); -#else - /* last points to one char beyond the start of the rightmost - substring. When s 0) ? i : last; if (dir > 0) { @@ -1863,17 +1827,7 @@ string_find_internal(PyStringObject *self, PyObject *args, int dir) if (pos < 0) return pos; return pos + i; - } -#endif - if (dir > 0) { - if (n == 0 && i <= last) - return (long)i; - last -= n; - for (; i <= last; ++i) - if (s[i] == sub[0] && memcmp(&s[i], sub, n) == 0) - return (long)i; - } - else { + } else { Py_ssize_t j; if (n == 0 && i <= last) @@ -2299,28 +2253,9 @@ string_count(PyStringObject *self, PyObject *args) if (n == 0) return PyInt_FromSsize_t(m-i); -#ifdef USE_FAST r = fastsearch(s + i, last - i, sub, n, FAST_COUNT); if (r < 0) r = 0; /* no match */ -#else - r = 0; - while (i < m) { - const char *t; - if (!memcmp(s+i, sub, n)) { - r++; - i += n; - } else { - i++; - } - if (i >= m) - break; - t = (const char *)memchr(s+i, sub[0], m-i); - if (t == NULL) - break; - i = t - s; - } -#endif return PyInt_FromSsize_t(r); }