[Python-checkins] cpython: Keep the definition of i consistent between set_lookkey() and

raymond.hettinger python-checkins at python.org
Sat Jan 31 11:45:31 CET 2015


https://hg.python.org/cpython/rev/33db20c8537c
changeset:   94416:33db20c8537c
user:        Raymond Hettinger <python at rcn.com>
date:        Sat Jan 31 02:45:12 2015 -0800
summary:
  Keep the definition of i consistent between set_lookkey() and set_insert_clean().

files:
  Objects/setobject.c |  8 ++++----
  1 files changed, 4 insertions(+), 4 deletions(-)


diff --git a/Objects/setobject.c b/Objects/setobject.c
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -56,11 +56,11 @@
     setentry *entry;
     size_t perturb = hash;
     size_t mask = so->mask;
-    size_t i = (size_t)hash; /* Unsigned for defined overflow behavior. */
+    size_t i = (size_t)hash & mask; /* Unsigned for defined overflow behavior */
     size_t j;
     int cmp;
 
-    entry = &table[i & mask];
+    entry = &table[i];
     if (entry->key == NULL)
         return entry;
 
@@ -116,9 +116,9 @@
         }
 
         perturb >>= PERTURB_SHIFT;
-        i = i * 5 + 1 + perturb;
+        i = (i * 5 + 1 + perturb) & mask;
 
-        entry = &table[i & mask];
+        entry = &table[i];
         if (entry->key == NULL)
             goto found_null;
     }

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


More information about the Python-checkins mailing list