summaryrefslogtreecommitdiffstats
path: root/Objects/setobject.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2015-07-23 11:42:23 (GMT)
committerRaymond Hettinger <python@rcn.com>2015-07-23 11:42:23 (GMT)
commit70559b5c2026ad7fc76996ef05571ac8e977ef26 (patch)
treeff73bbcfcec7f7db7813c616dce11d71d809d963 /Objects/setobject.c
parent6d35043e4960717dfbdafc55493286f5eafe5b9a (diff)
downloadcpython-70559b5c2026ad7fc76996ef05571ac8e977ef26.zip
cpython-70559b5c2026ad7fc76996ef05571ac8e977ef26.tar.gz
cpython-70559b5c2026ad7fc76996ef05571ac8e977ef26.tar.bz2
Issue #24681: Move the store of so->table to the code block where it is used.
Diffstat (limited to 'Objects/setobject.c')
-rw-r--r--Objects/setobject.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 3c4c484..0e443c4 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -50,7 +50,7 @@ static PyObject _dummy_struct;
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 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
size_t j;
int cmp;
- entry = &table[i];
+ entry = &so->table[i];
if (entry->key == NULL)
return entry;
@@ -75,6 +75,7 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
&& 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 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
&& 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 @@ set_lookkey(PySetObject *so, PyObject *key, Py_hash_t hash)
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 @@ set_add_entry(PySetObject *so, PyObject *key, Py_hash_t hash)
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,6 +167,7 @@ set_add_entry(PySetObject *so, PyObject *key, Py_hash_t hash)
&& 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);
@@ -177,7 +179,7 @@ set_add_entry(PySetObject *so, PyObject *key, Py_hash_t hash)
goto found_active;
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,6 +196,7 @@ set_add_entry(PySetObject *so, PyObject *key, Py_hash_t hash)
&& 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);
@@ -213,7 +216,7 @@ set_add_entry(PySetObject *so, PyObject *key, Py_hash_t hash)
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;
}