Tighten inner-loop for deque_inplace_repeat().
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 49a46a1..087f8e5 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -568,7 +568,7 @@
return PyErr_NoMemory();
deque->state++;
- for (i = 0 ; i < n-1 ; i++) {
+ for (i = 0 ; i < n-1 ; ) {
if (deque->rightindex == BLOCKLEN - 1) {
block *b = newblock(Py_SIZE(deque) + i);
if (b == NULL) {
@@ -582,9 +582,11 @@
MARK_END(b->rightlink);
deque->rightindex = -1;
}
- deque->rightindex++;
- Py_INCREF(item);
- deque->rightblock->data[deque->rightindex] = item;
+ for ( ; i < n-1 && deque->rightindex != BLOCKLEN - 1 ; i++) {
+ deque->rightindex++;
+ Py_INCREF(item);
+ deque->rightblock->data[deque->rightindex] = item;
+ }
}
Py_SIZE(deque) += i;
Py_INCREF(deque);