diff options
author | Raymond Hettinger <python@rcn.com> | 2013-09-21 21:02:55 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2013-09-21 21:02:55 (GMT) |
commit | c70a2b7bb90cac8fd65aaeaf62e36c0945b93243 (patch) | |
tree | eb0c620862c1fbc205a661d256a8640c7327de8c /Objects | |
parent | 1eb87629cd975c5219eb3b6d7759fca0d77330b2 (diff) | |
download | cpython-c70a2b7bb90cac8fd65aaeaf62e36c0945b93243.zip cpython-c70a2b7bb90cac8fd65aaeaf62e36c0945b93243.tar.gz cpython-c70a2b7bb90cac8fd65aaeaf62e36c0945b93243.tar.bz2 |
Make the linear probe sequence clearer.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/setobject.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c index ece76bf..05b672f 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -62,7 +62,6 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash) size_t i = (size_t)hash; /* Unsigned for defined overflow behavior. */ int cmp; #if LINEAR_PROBES - setentry *limit; size_t j; #endif @@ -89,9 +88,8 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash) freeslot = entry; #if LINEAR_PROBES - limit = &table[mask]; - for (j = 0 ; j < LINEAR_PROBES ; j++) { - entry = (entry == limit) ? &table[0] : entry + 1; + for (j = 1 ; j <= LINEAR_PROBES ; j++) { + entry = &table[(i + j) & mask]; if (entry->key == NULL) goto found_null; if (entry->key == key) @@ -139,7 +137,6 @@ set_lookkey_unicode(PySetObject *so, PyObject *key, Py_hash_t hash) size_t mask = so->mask; size_t i = (size_t)hash; #if LINEAR_PROBES - setentry *limit; size_t j; #endif @@ -166,9 +163,8 @@ set_lookkey_unicode(PySetObject *so, PyObject *key, Py_hash_t hash) freeslot = entry; #if LINEAR_PROBES - limit = &table[mask]; - for (j = 0 ; j < LINEAR_PROBES ; j++) { - entry = (entry == limit) ? &table[0] : entry + 1; + for (j = 1 ; j <= LINEAR_PROBES ; j++) { + entry = &table[(i + j) & mask]; if (entry->key == NULL) goto found_null; if (entry->key == key |