]> granicus.if.org Git - python/commitdiff
Simplify heuristic for when to use memchr
authorAntoine Pitrou <solipsis@pitrou.net>
Thu, 13 Oct 2011 15:58:11 +0000 (17:58 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Thu, 13 Oct 2011 15:58:11 +0000 (17:58 +0200)
Objects/stringlib/fastsearch.h

index 085ec6a3d2b8333089d6d4ea5d5cf0bafe426c63..0f7aea74a985495d147ffd80f5b7d29ecd5b4257 100644 (file)
@@ -113,20 +113,10 @@ FASTSEARCH(const STRINGLIB_CHAR* s, Py_ssize_t n,
             /* use memchr if we can choose a needle without two many likely
                false positives */
             unsigned char needle;
-            int use_needle = 1;
             needle = p[0] & 0xff;
 #if STRINGLIB_SIZEOF_CHAR > 1
-            if (needle == 0) {
-                needle = (p[0] >> 8) & 0xff;
-#if STRINGLIB_SIZEOF_CHAR > 2
-                if (needle == 0)
-                    needle = (p[0] >> 16) & 0xff;
+            if (needle != 0)
 #endif
-                if (needle >= 32 || needle == 0)
-                    use_needle = 0;
-            }
-#endif
-            if (use_needle)
                 return STRINGLIB(fastsearch_memchr_1char)
                        (s, n, p[0], needle, maxcount, mode);
         }