[Python-checkins] cpython (2.7): avoid a function call with redundant checks for dict size

benjamin.peterson python-checkins at python.org
Wed Oct 31 19:24:26 CET 2012


http://hg.python.org/cpython/rev/9c388672279d
changeset:   80118:9c388672279d
branch:      2.7
user:        Benjamin Peterson <benjamin at python.org>
date:        Wed Oct 31 14:22:12 2012 -0400
summary:
  avoid a function call with redundant checks for dict size

files:
  Objects/dictobject.c |  2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/Objects/dictobject.c b/Objects/dictobject.c
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1353,7 +1353,7 @@
     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;

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list