summaryrefslogtreecommitdiffstats
path: root/Modules/_collectionsmodule.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2015-02-02 06:53:41 (GMT)
committerRaymond Hettinger <python@rcn.com>2015-02-02 06:53:41 (GMT)
commit0e259f18f7ada32dd1a37ac883ea17df9c60bc53 (patch)
treea66b9a67f324adac1124110440f39ac432f4fe97 /Modules/_collectionsmodule.c
parent5d0bb852a25d010cc1aacf661d26a6bae1c8bf1a (diff)
downloadcpython-0e259f18f7ada32dd1a37ac883ea17df9c60bc53.zip
cpython-0e259f18f7ada32dd1a37ac883ea17df9c60bc53.tar.gz
cpython-0e259f18f7ada32dd1a37ac883ea17df9c60bc53.tar.bz2
Optimization guides suggest copying memory in an ascending direction when possible.
Diffstat (limited to 'Modules/_collectionsmodule.c')
-rw-r--r--Modules/_collectionsmodule.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index b2783d2..69d93ae 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -534,13 +534,13 @@ _deque_rotate(dequeobject *deque, Py_ssize_t n)
if (m > leftindex)
m = leftindex;
assert (m > 0 && m <= len);
- src = &rightblock->data[rightindex];
- dest = &leftblock->data[leftindex - 1];
rightindex -= m;
leftindex -= m;
+ src = &rightblock->data[rightindex + 1];
+ dest = &leftblock->data[leftindex];
n -= m;
do {
- *(dest--) = *(src--);
+ *(dest++) = *(src++);
} while (--m);
}
if (rightindex == -1) {