diff options
author | Raymond Hettinger <python@rcn.com> | 2015-02-03 16:15:30 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-02-03 16:15:30 (GMT) |
commit | 06bb1226d18e657a36ddd492ec88c16c9108323b (patch) | |
tree | 5180378e4e9d2e29e0812dbfecd0f25cd29d21f3 /Objects/setobject.c | |
parent | 5178d91be09d73900699655b3ddecc0482e7942f (diff) | |
download | cpython-06bb1226d18e657a36ddd492ec88c16c9108323b.zip cpython-06bb1226d18e657a36ddd492ec88c16c9108323b.tar.gz cpython-06bb1226d18e657a36ddd492ec88c16c9108323b.tar.bz2 |
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 :-)
Diffstat (limited to 'Objects/setobject.c')
-rw-r--r-- | Objects/setobject.c | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c index ff832d5..9bdbbba 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -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; |