]> 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 664b58c8c5bcf12b19fa7d2c605547bd2e13681f..ba36b180cad23a48fd9671ba268961e57a334524 100644 (file)
@@ -1353,7 +1353,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;