From: Raymond Hettinger Date: Mon, 2 Feb 2015 06:53:41 +0000 (-0800) Subject: Optimization guides suggest copying memory in an ascending direction when possible. X-Git-Tag: v3.5.0a1~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e259f18f7ada32dd1a37ac883ea17df9c60bc53;p=thirdparty%2FPython%2Fcpython.git Optimization guides suggest copying memory in an ascending direction when possible. --- diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index b2783d273958..69d93ae6a69c 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) {