[Python-checkins] cpython: Neaten-up the inner-loop logic.

raymond.hettinger python-checkins at python.org
Tue Nov 3 22:00:30 EST 2015


https://hg.python.org/cpython/rev/aba28afc5732
changeset:   98948:aba28afc5732
user:        Raymond Hettinger <python at rcn.com>
date:        Tue Nov 03 22:00:26 2015 -0500
summary:
  Neaten-up the inner-loop logic.

files:
  Modules/_collectionsmodule.c |  6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)


diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -1053,13 +1053,13 @@
         }
     }
 
-    n = stop - i;
-    while (n--) {
+    n = stop - i + 1;
+    while (--n) {
         CHECK_NOT_END(b);
         item = b->data[index];
         cmp = PyObject_RichCompareBool(item, v, Py_EQ);
         if (cmp > 0)
-            return PyLong_FromSsize_t(stop - (n + 1));
+            return PyLong_FromSsize_t(stop - n);
         if (cmp < 0)
             return NULL;
         if (start_state != deque->state) {

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


More information about the Python-checkins mailing list