mirror of
https://github.com/python/cpython.git
synced 2025-11-03 11:23:31 +00:00
Tighten inner-loop for deque_inplace_repeat().
This commit is contained in:
parent
e4f3467df1
commit
ad26225e1a
1 changed files with 6 additions and 4 deletions
|
|
@ -568,7 +568,7 @@ deque_inplace_repeat(dequeobject *deque, Py_ssize_t n)
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
|
|
||||||
deque->state++;
|
deque->state++;
|
||||||
for (i = 0 ; i < n-1 ; i++) {
|
for (i = 0 ; i < n-1 ; ) {
|
||||||
if (deque->rightindex == BLOCKLEN - 1) {
|
if (deque->rightindex == BLOCKLEN - 1) {
|
||||||
block *b = newblock(Py_SIZE(deque) + i);
|
block *b = newblock(Py_SIZE(deque) + i);
|
||||||
if (b == NULL) {
|
if (b == NULL) {
|
||||||
|
|
@ -582,9 +582,11 @@ deque_inplace_repeat(dequeobject *deque, Py_ssize_t n)
|
||||||
MARK_END(b->rightlink);
|
MARK_END(b->rightlink);
|
||||||
deque->rightindex = -1;
|
deque->rightindex = -1;
|
||||||
}
|
}
|
||||||
deque->rightindex++;
|
for ( ; i < n-1 && deque->rightindex != BLOCKLEN - 1 ; i++) {
|
||||||
Py_INCREF(item);
|
deque->rightindex++;
|
||||||
deque->rightblock->data[deque->rightindex] = item;
|
Py_INCREF(item);
|
||||||
|
deque->rightblock->data[deque->rightindex] = item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Py_SIZE(deque) += i;
|
Py_SIZE(deque) += i;
|
||||||
Py_INCREF(deque);
|
Py_INCREF(deque);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue