]> granicus.if.org Git - python/commitdiff
Call set_lookkey() directly to avoid unnecessary memory spills and reloads.
authorRaymond Hettinger <python@rcn.com>
Sat, 4 Jul 2015 01:31:09 +0000 (18:31 -0700)
committerRaymond Hettinger <python@rcn.com>
Sat, 4 Jul 2015 01:31:09 +0000 (18:31 -0700)
Objects/setobject.c

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