]> granicus.if.org Git - python/commitdiff
avoid a function call with redundant checks for dict size
authorBenjamin Peterson <benjamin@python.org>
Wed, 31 Oct 2012 18:22:12 +0000 (14:22 -0400)
committerBenjamin Peterson <benjamin@python.org>
Wed, 31 Oct 2012 18:22:12 +0000 (14:22 -0400)
Objects/dictobject.c

index d3c5eac37071bab39e1075577bba7209ea790f8b..c10bfccdce679b8debde945a945a75fd7b2f4c96 100644 (file)
@@ -1335,7 +1335,7 @@ dict_fromkeys(PyObject *cls, PyObject *args)
     if (d == NULL)
         return NULL;
 
-    if (PyDict_CheckExact(d) && PyDict_Size(d) == 0) {
+    if (PyDict_CheckExact(d) && ((PyDictObject *)d)->ma_used == 0) {
         if (PyDict_CheckExact(seq)) {
             PyDictObject *mp = (PyDictObject *)d;
             PyObject *oldvalue;