diff --git a/Objects/setobject.c b/Objects/setobject.c --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -50,7 +50,7 @@ static setentry * set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash) { - setentry *table = so->table; + setentry *table; setentry *entry; size_t perturb; size_t mask = so->mask; @@ -58,7 +58,7 @@ size_t j; int cmp; - entry = &table[i]; + entry = &so->table[i]; if (entry->key == NULL) return entry; @@ -75,6 +75,7 @@ && PyUnicode_CheckExact(key) && _PyUnicode_EQ(startkey, key)) return entry; + table = so->table; Py_INCREF(startkey); cmp = PyObject_RichCompareBool(startkey, key, Py_EQ); Py_DECREF(startkey); @@ -101,6 +102,7 @@ && PyUnicode_CheckExact(key) && _PyUnicode_EQ(startkey, key)) return entry; + table = so->table; Py_INCREF(startkey); cmp = PyObject_RichCompareBool(startkey, key, Py_EQ); Py_DECREF(startkey); @@ -118,7 +120,7 @@ perturb >>= PERTURB_SHIFT; i = (i * 5 + 1 + perturb) & mask; - entry = &table[i]; + entry = &so->table[i]; if (entry->key == NULL) return entry; } @@ -144,11 +146,10 @@ restart: - table = so->table; mask = so->mask; i = (size_t)hash & mask; - entry = &table[i]; + entry = &so->table[i]; if (entry->key == NULL) goto found_unused; @@ -166,18 +167,19 @@ && PyUnicode_CheckExact(key) && _PyUnicode_EQ(startkey, key)) goto found_active; + table = so->table; Py_INCREF(startkey); cmp = PyObject_RichCompareBool(startkey, key, Py_EQ); Py_DECREF(startkey); - if (cmp < 0) /* unlikely */ - goto comparison_error; - if (table != so->table || entry->key != startkey) /* unlikely */ - goto restart; if (cmp > 0) /* likely */ goto found_active; + if (cmp < 0) + goto comparison_error; + if (table != so->table || entry->key != startkey) + goto restart; mask = so->mask; /* help avoid a register spill */ } - if (entry->hash == -1 && freeslot == NULL) + else if (entry->hash == -1 && freeslot == NULL) freeslot = entry; if (i + LINEAR_PROBES <= mask) { @@ -194,15 +196,16 @@ && PyUnicode_CheckExact(key) && _PyUnicode_EQ(startkey, key)) goto found_active; + table = so->table; Py_INCREF(startkey); cmp = PyObject_RichCompareBool(startkey, key, Py_EQ); Py_DECREF(startkey); + if (cmp > 0) + goto found_active; if (cmp < 0) goto comparison_error; if (table != so->table || entry->key != startkey) goto restart; - if (cmp > 0) - goto found_active; mask = so->mask; } else if (entry->hash == -1 && freeslot == NULL) @@ -213,7 +216,7 @@ perturb >>= PERTURB_SHIFT; i = (i * 5 + 1 + perturb) & mask; - entry = &table[i]; + entry = &so->table[i]; if (entry->key == NULL) goto found_unused_or_dummy; }