]> granicus.if.org Git - python/commitdiff
Convert two other post-decrement while-loops to pre-decrements for consistency
authorRaymond Hettinger <python@rcn.com>
Sun, 24 Jan 2016 19:32:07 +0000 (11:32 -0800)
committerRaymond Hettinger <python@rcn.com>
Sun, 24 Jan 2016 19:32:07 +0000 (11:32 -0800)
and for better code generation.

Modules/_collectionsmodule.c

index 3ab987daee8450557aabaf57a450b7cc8033971f..cc9e4e890ed09bb4f9f066ab6099e9b8c9dd9979 100644 (file)
@@ -937,7 +937,8 @@ deque_count(dequeobject *deque, PyObject *v)
     PyObject *item;
     int cmp;
 
-    while (n--) {
+    n++;
+    while (--n) {
         CHECK_NOT_END(b);
         item = b->data[index];
         cmp = PyObject_RichCompareBool(item, v, Py_EQ);
@@ -974,7 +975,8 @@ deque_contains(dequeobject *deque, PyObject *v)
     PyObject *item;
     int cmp;
 
-    while (n--) {
+    n++;
+    while (--n) {
         CHECK_NOT_END(b);
         item = b->data[index];
         cmp = PyObject_RichCompareBool(item, v, Py_EQ);