[Python-checkins] cpython: Simplify heuristic for when to use memchr

antoine.pitrou python-checkins at python.org
Thu Oct 13 18:05:06 CEST 2011


http://hg.python.org/cpython/rev/c61137ff5f52
changeset:   72910:c61137ff5f52
parent:      72908:4a6709a071d0
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Thu Oct 13 17:58:11 2011 +0200
summary:
  Simplify heuristic for when to use memchr

files:
  Objects/stringlib/fastsearch.h |  12 +-----------
  1 files changed, 1 insertions(+), 11 deletions(-)


diff --git a/Objects/stringlib/fastsearch.h b/Objects/stringlib/fastsearch.h
--- a/Objects/stringlib/fastsearch.h
+++ b/Objects/stringlib/fastsearch.h
@@ -113,20 +113,10 @@
             /* 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);
         }

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list