]> granicus.if.org Git - python/commitdiff
Convert another post-decrement while-loop to pre-decrement for consistency
authorRaymond Hettinger <python@rcn.com>
Sun, 24 Jan 2016 20:40:42 +0000 (12:40 -0800)
committerRaymond Hettinger <python@rcn.com>
Sun, 24 Jan 2016 20:40:42 +0000 (12:40 -0800)
and better generated code (on both GCC and CLang).

Modules/_collectionsmodule.c

index cc9e4e890ed09bb4f9f066ab6099e9b8c9dd9979..b77ea652fbd2eb9db8c49bf4ae475e964ea33537 100644 (file)
@@ -895,7 +895,8 @@ deque_reverse(dequeobject *deque, PyObject *unused)
     Py_ssize_t n = Py_SIZE(deque) >> 1;
     PyObject *tmp;
 
-    while (n-- > 0) {
+    n++;
+    while (--n) {
         /* Validate that pointers haven't met in the middle */
         assert(leftblock != rightblock || leftindex < rightindex);
         CHECK_NOT_END(leftblock);