mirror of https://github.com/python/cpython
Refactor deque_traverse().
Hoist conditional expression out of the loop. Use rightblock as the guard instead of checking for NULL.
This commit is contained in:
parent
98054b4c1b
commit
5bfa8671bc
|
@ -805,17 +805,17 @@ deque_traverse(dequeobject *deque, visitproc visit, void *arg)
|
||||||
Py_ssize_t index;
|
Py_ssize_t index;
|
||||||
Py_ssize_t indexlo = deque->leftindex;
|
Py_ssize_t indexlo = deque->leftindex;
|
||||||
|
|
||||||
for (b = deque->leftblock; b != NULL; b = b->rightlink) {
|
for (b = deque->leftblock; b != deque->rightblock; b = b->rightlink) {
|
||||||
const Py_ssize_t indexhi = b == deque->rightblock ?
|
for (index = indexlo; index < BLOCKLEN ; index++) {
|
||||||
deque->rightindex :
|
|
||||||
BLOCKLEN - 1;
|
|
||||||
|
|
||||||
for (index = indexlo; index <= indexhi; ++index) {
|
|
||||||
item = b->data[index];
|
item = b->data[index];
|
||||||
Py_VISIT(item);
|
Py_VISIT(item);
|
||||||
}
|
}
|
||||||
indexlo = 0;
|
indexlo = 0;
|
||||||
}
|
}
|
||||||
|
for (index = indexlo; index <= deque->rightindex; index++) {
|
||||||
|
item = b->data[index];
|
||||||
|
Py_VISIT(item);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue