From: Raymond Hettinger Date: Sun, 14 Jul 2013 00:03:58 +0000 (-0700) Subject: Use a do-while loop in the inner loop for rotate (m is always greater than zero). X-Git-Tag: v3.4.0a1~218 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=840533bf1c7e5cb9b565067795df28a41b61844e;p=thirdparty%2FPython%2Fcpython.git Use a do-while loop in the inner loop for rotate (m is always greater than zero). --- diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 44ed0b2f6a6e..21cc21dac9fd 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -506,13 +506,15 @@ _deque_rotate(dequeobject *deque, Py_ssize_t n) rightindex -= m; leftindex -= m; n -= m; - while (m--) + do { *(dest--) = *(src--); + } while (--m); } if (rightindex == -1) { block *prevblock = rightblock->leftlink; assert(leftblock != rightblock); + assert(b == NULL); b = rightblock; CHECK_NOT_END(prevblock); MARK_END(prevblock->rightlink); @@ -551,13 +553,15 @@ _deque_rotate(dequeobject *deque, Py_ssize_t n) leftindex += m; rightindex += m; n += m; - while (m--) + do { *(dest++) = *(src++); + } while (--m); } if (leftindex == BLOCKLEN) { block *nextblock = leftblock->rightlink; assert(leftblock != rightblock); + assert(b == NULL); b = leftblock; CHECK_NOT_END(nextblock); MARK_END(nextblock->leftlink);