summaryrefslogtreecommitdiffstats
path: root/Objects/setobject.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2015-06-21 04:39:51 (GMT)
committerRaymond Hettinger <python@rcn.com>2015-06-21 04:39:51 (GMT)
commit6ee588f14e23206db3c927653956fd35f6ca857a (patch)
tree7f2e949e95d6b8eb924850dbc068f0a4f8fcdaaf /Objects/setobject.c
parent81fdd0b86855062687290352f63e3c6cf6131a22 (diff)
downloadcpython-6ee588f14e23206db3c927653956fd35f6ca857a.zip
cpython-6ee588f14e23206db3c927653956fd35f6ca857a.tar.gz
cpython-6ee588f14e23206db3c927653956fd35f6ca857a.tar.bz2
Restore quick exit (no freeslot check) for common case (found null on first probe).
Diffstat (limited to 'Objects/setobject.c')
-rw-r--r--Objects/setobject.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 707ab95..d621647 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -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 */