]> granicus.if.org Git - python/commitdiff
Restore quick exit (no freeslot check) for common case (found null on first probe).
authorRaymond Hettinger <python@rcn.com>
Sun, 21 Jun 2015 04:39:51 +0000 (21:39 -0700)
committerRaymond Hettinger <python@rcn.com>
Sun, 21 Jun 2015 04:39:51 +0000 (21:39 -0700)
Objects/setobject.c

index 707ab95646c664b485121fe4176651498cdd96f6..d62164773bc2acd7b76eb6d7bef4fca01c372677 100644 (file)
@@ -142,7 +142,10 @@ set_insert_key(PySetObject *so, PyObject *key, Py_hash_t hash)
 
     entry = &table[i];
     if (entry->key == NULL)
-        goto found_null;
+        goto found_null_first;
+
+    freeslot = NULL;
+    perturb = hash;
 
     while (1) {
         if (entry->hash == hash) {
@@ -207,6 +210,13 @@ set_insert_key(PySetObject *so, PyObject *key, Py_hash_t hash)
             goto found_null;
     }
 
+  found_null_first:
+    so->fill++;
+    so->used++;
+    entry->key = key;
+    entry->hash = hash;
+    return 0;
+
   found_null:
     if (freeslot == NULL) {
         /* UNUSED */