]> granicus.if.org Git - python/commitdiff
Issue 23359: Reduce size of code in set_lookkey. Only do linear probes when there...
authorRaymond Hettinger <python@rcn.com>
Tue, 3 Feb 2015 16:15:30 +0000 (08:15 -0800)
committerRaymond Hettinger <python@rcn.com>
Tue, 3 Feb 2015 16:15:30 +0000 (08:15 -0800)
Nice simplification contributed by Serhiy Storchaka :-)

Objects/setobject.c

index ff832d55bb50f1e1306b096e97161ebafe5104a7..9bdbbba19c7116434696a1936804ca7ad424ca33 100644 (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;