summaryrefslogtreecommitdiffstats
path: root/Modules/_collectionsmodule.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2013-07-14 00:03:58 (GMT)
committerRaymond Hettinger <python@rcn.com>2013-07-14 00:03:58 (GMT)
commit840533bf1c7e5cb9b565067795df28a41b61844e (patch)
tree801a269bf74cd768cf451a91aee9d2ef66109572 /Modules/_collectionsmodule.c
parent3959af9b2a52a71ab329d3850c9e3fe72bd7a7cc (diff)
downloadcpython-840533bf1c7e5cb9b565067795df28a41b61844e.zip
cpython-840533bf1c7e5cb9b565067795df28a41b61844e.tar.gz
cpython-840533bf1c7e5cb9b565067795df28a41b61844e.tar.bz2
Use a do-while loop in the inner loop for rotate (m is always greater than zero).
Diffstat (limited to 'Modules/_collectionsmodule.c')
-rw-r--r--Modules/_collectionsmodule.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 44ed0b2..21cc21d 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);