mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue #24681: Move the most likely test first in set_add_entry().
This commit is contained in:
parent
746f6af715
commit
daffc916aa
1 changed files with 9 additions and 6 deletions
|
@ -171,12 +171,15 @@ set_add_entry(PySetObject *so, PyObject *key, Py_hash_t hash)
|
||||||
Py_INCREF(startkey);
|
Py_INCREF(startkey);
|
||||||
cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
|
cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
|
||||||
Py_DECREF(startkey);
|
Py_DECREF(startkey);
|
||||||
if (cmp < 0) /* unlikely */
|
|
||||||
goto comparison_error;
|
|
||||||
if (table != so->table || entry->key != startkey) /* unlikely */
|
|
||||||
goto restart;
|
|
||||||
if (cmp > 0) /* likely */
|
if (cmp > 0) /* likely */
|
||||||
goto found_active;
|
goto found_active;
|
||||||
|
if (cmp < 0)
|
||||||
|
goto comparison_error;
|
||||||
|
/* Continuing the search from the current entry only makes
|
||||||
|
sense if the table and entry are unchanged; otherwise,
|
||||||
|
we have to restart from the beginning */
|
||||||
|
if (table != so->table || entry->key != startkey)
|
||||||
|
goto restart;
|
||||||
mask = so->mask; /* help avoid a register spill */
|
mask = so->mask; /* help avoid a register spill */
|
||||||
}
|
}
|
||||||
else if (entry->hash == -1 && freeslot == NULL)
|
else if (entry->hash == -1 && freeslot == NULL)
|
||||||
|
@ -200,12 +203,12 @@ set_add_entry(PySetObject *so, PyObject *key, Py_hash_t hash)
|
||||||
Py_INCREF(startkey);
|
Py_INCREF(startkey);
|
||||||
cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
|
cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
|
||||||
Py_DECREF(startkey);
|
Py_DECREF(startkey);
|
||||||
|
if (cmp > 0)
|
||||||
|
goto found_active;
|
||||||
if (cmp < 0)
|
if (cmp < 0)
|
||||||
goto comparison_error;
|
goto comparison_error;
|
||||||
if (table != so->table || entry->key != startkey)
|
if (table != so->table || entry->key != startkey)
|
||||||
goto restart;
|
goto restart;
|
||||||
if (cmp > 0)
|
|
||||||
goto found_active;
|
|
||||||
mask = so->mask;
|
mask = so->mask;
|
||||||
}
|
}
|
||||||
else if (entry->hash == -1 && freeslot == NULL)
|
else if (entry->hash == -1 && freeslot == NULL)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue