From 6ee588f14e23206db3c927653956fd35f6ca857a Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sat, 20 Jun 2015 21:39:51 -0700 Subject: Restore quick exit (no freeslot check) for common case (found null on first probe). --- Objects/setobject.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 */ -- cgit v0.12