Issue 23359: Reduce size of code in set_lookkey. Only do linear probes when there is no wrap-around.

Nice simplification contributed by Serhiy Storchaka :-)
This commit is contained in:
Raymond Hettinger 2015-02-03 08:15:30 -08:00
parent 5178d91be0
commit 06bb1226d1
1 changed files with 0 additions and 33 deletions

View File

@ -115,33 +115,6 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
if (entry->key == dummy && freeslot == NULL)
freeslot = entry;
}
} else {
for (j = 1 ; j <= LINEAR_PROBES ; j++) {
entry = &table[(i + j) & mask];
if (entry->key == NULL)
goto found_null;
if (entry->hash == hash) {
PyObject *startkey = entry->key;
assert(startkey != dummy);
if (startkey == key)
return entry;
if (PyUnicode_CheckExact(startkey)
&& PyUnicode_CheckExact(key)
&& unicode_eq(startkey, key))
return entry;
Py_INCREF(startkey);
cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
Py_DECREF(startkey);
if (cmp < 0)
return NULL;
if (table != so->table || entry->key != startkey)
return set_lookkey(so, key, hash);
if (cmp > 0)
return entry;
}
if (entry->key == dummy && freeslot == NULL)
freeslot = entry;
}
}
perturb >>= PERTURB_SHIFT;
@ -183,12 +156,6 @@ set_insert_clean(PySetObject *so, PyObject *key, Py_hash_t hash)
if (entry->key == NULL)
goto found_null;
}
} else {
for (j = 1; j <= LINEAR_PROBES; j++) {
entry = &table[(i + j) & mask];
if (entry->key == NULL)
goto found_null;
}
}
perturb >>= PERTURB_SHIFT;
i = (i * 5 + 1 + perturb) & mask;