summaryrefslogtreecommitdiffstats
path: root/Objects/setobject.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2015-01-31 10:45:12 (GMT)
committerRaymond Hettinger <python@rcn.com>2015-01-31 10:45:12 (GMT)
commit59ecabd12a173e6b176b70ba9a4292adec3ba31d (patch)
treeeb9cfd5511a49fd903aa4cac83a7bebcdb35d93e /Objects/setobject.c
parent260cd320a1087fa040743fd46dd0d2c412a0ba17 (diff)
downloadcpython-59ecabd12a173e6b176b70ba9a4292adec3ba31d.zip
cpython-59ecabd12a173e6b176b70ba9a4292adec3ba31d.tar.gz
cpython-59ecabd12a173e6b176b70ba9a4292adec3ba31d.tar.bz2
Keep the definition of i consistent between set_lookkey() and set_insert_clean().
Diffstat (limited to 'Objects/setobject.c')
-rw-r--r--Objects/setobject.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 7236dd5..021b83e 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -56,11 +56,11 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
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 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
}
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;
}