[Python-checkins] cpython: Tighten inner-loop for deque_inplace_repeat().
raymond.hettinger
python-checkins at python.org
Mon Sep 14 07:03:09 CEST 2015
https://hg.python.org/cpython/rev/c2c4400bb12c
changeset: 97999:c2c4400bb12c
user: Raymond Hettinger <python at rcn.com>
date: Mon Sep 14 01:03:04 2015 -0400
summary:
Tighten inner-loop for deque_inplace_repeat().
files:
Modules/_collectionsmodule.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
--- 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);
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list