[Python-checkins] cpython: this is expressed better as a for loop

benjamin.peterson python-checkins at python.org
Mon Jul 4 00:19:15 CEST 2011


http://hg.python.org/cpython/rev/36df19f9e94b
changeset:   71161:36df19f9e94b
user:        Benjamin Peterson <benjamin at python.org>
date:        Sun Jul 03 17:23:22 2011 -0500
summary:
  this is expressed better as a for loop

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


diff --git a/Objects/genobject.c b/Objects/genobject.c
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -395,15 +395,13 @@
     int i;
     PyFrameObject *f = gen->gi_frame;
 
-    if (f == NULL || f->f_stacktop == NULL || f->f_iblock <= 0)
+    if (f == NULL || f->f_stacktop == NULL)
         return 0; /* no frame or empty blockstack == no finalization */
 
     /* Any block type besides a loop requires cleanup. */
-    i = f->f_iblock;
-    while (--i >= 0) {
+    for (i = 0; i < f->f_iblock; i++)
         if (f->f_blockstack[i].b_type != SETUP_LOOP)
             return 1;
-    }
 
     /* No blocks except loops, it's safe to skip finalization. */
     return 0;

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


More information about the Python-checkins mailing list