Call set_lookkey() directly to avoid unnecessary memory spills and reloads.

This commit is contained in:
Raymond Hettinger 2015-07-03 18:31:09 -07:00
parent 15f0869609
commit 3c1f52e829
1 changed files with 5 additions and 4 deletions

View File

@ -678,7 +678,7 @@ set_contains_entry(PySetObject *so, setentry *entry)
static int static int
set_contains_key(PySetObject *so, PyObject *key) set_contains_key(PySetObject *so, PyObject *key)
{ {
setentry entry; setentry *entry;
Py_hash_t hash; Py_hash_t hash;
if (!PyUnicode_CheckExact(key) || if (!PyUnicode_CheckExact(key) ||
@ -687,9 +687,10 @@ set_contains_key(PySetObject *so, PyObject *key)
if (hash == -1) if (hash == -1)
return -1; return -1;
} }
entry.key = key; entry = set_lookkey(so, key, hash);
entry.hash = hash; if (entry == NULL)
return set_contains_entry(so, &entry); return -1;
return entry->key != NULL;
} }
static PyObject * static PyObject *