mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Restore quick exit (no freeslot check) for common case (found null on first probe).
This commit is contained in:
parent
81fdd0b868
commit
6ee588f14e
1 changed files with 11 additions and 1 deletions
|
@ -142,7 +142,10 @@ set_insert_key(PySetObject *so, PyObject *key, Py_hash_t hash)
|
||||||
|
|
||||||
entry = &table[i];
|
entry = &table[i];
|
||||||
if (entry->key == NULL)
|
if (entry->key == NULL)
|
||||||
goto found_null;
|
goto found_null_first;
|
||||||
|
|
||||||
|
freeslot = NULL;
|
||||||
|
perturb = hash;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (entry->hash == hash) {
|
if (entry->hash == hash) {
|
||||||
|
@ -207,6 +210,13 @@ set_insert_key(PySetObject *so, PyObject *key, Py_hash_t hash)
|
||||||
goto found_null;
|
goto found_null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
found_null_first:
|
||||||
|
so->fill++;
|
||||||
|
so->used++;
|
||||||
|
entry->key = key;
|
||||||
|
entry->hash = hash;
|
||||||
|
return 0;
|
||||||
|
|
||||||
found_null:
|
found_null:
|
||||||
if (freeslot == NULL) {
|
if (freeslot == NULL) {
|
||||||
/* UNUSED */
|
/* UNUSED */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue