[Python-checkins] cpython (2.7): Issue 18719: Remove a false optimization

raymond.hettinger python-checkins at python.org
Wed Aug 14 03:35:13 CEST 2013


http://hg.python.org/cpython/rev/ac2f59a6637f
changeset:   85168:ac2f59a6637f
branch:      2.7
parent:      85165:22d7c755163d
user:        Raymond Hettinger <python at rcn.com>
date:        Tue Aug 13 18:34:49 2013 -0700
summary:
  Issue 18719: Remove a false optimization

Remove an unused early-out test from the critical path for
dict and set lookups.

When the strings already have matching lengths and hashes,
there is no additional information gained by checking the first
characters (the probability of a mismatch is already known to
be less than 1 in 2**64).

files:
  Objects/stringobject.c |  1 -
  1 files changed, 0 insertions(+), 1 deletions(-)


diff --git a/Objects/stringobject.c b/Objects/stringobject.c
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -1255,7 +1255,6 @@
     PyStringObject *a = (PyStringObject*) o1;
     PyStringObject *b = (PyStringObject*) o2;
     return Py_SIZE(a) == Py_SIZE(b)
-      && *a->ob_sval == *b->ob_sval
       && memcmp(a->ob_sval, b->ob_sval, Py_SIZE(a)) == 0;
 }
 

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


More information about the Python-checkins mailing list