summaryrefslogtreecommitdiffstats
path: root/Modules/_collectionsmodule.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2013-07-06 21:58:09 (GMT)
committerRaymond Hettinger <python@rcn.com>2013-07-06 21:58:09 (GMT)
commit5bfa8671bcce1fbac3964f13f5f93489f2be7da9 (patch)
tree275f2b9c121b33ec56c000ffe822ec53a338c72e /Modules/_collectionsmodule.c
parent98054b4c1be933f5bbfb3c1a1f4ee3f556dd47ca (diff)
downloadcpython-5bfa8671bcce1fbac3964f13f5f93489f2be7da9.zip
cpython-5bfa8671bcce1fbac3964f13f5f93489f2be7da9.tar.gz
cpython-5bfa8671bcce1fbac3964f13f5f93489f2be7da9.tar.bz2
Refactor deque_traverse().
Hoist conditional expression out of the loop. Use rightblock as the guard instead of checking for NULL.
Diffstat (limited to 'Modules/_collectionsmodule.c')
-rw-r--r--Modules/_collectionsmodule.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 376a8e6..0a98e01 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -805,17 +805,17 @@ deque_traverse(dequeobject *deque, visitproc visit, void *arg)
Py_ssize_t index;
Py_ssize_t indexlo = deque->leftindex;
- for (b = deque->leftblock; b != NULL; b = b->rightlink) {
- const Py_ssize_t indexhi = b == deque->rightblock ?
- deque->rightindex :
- BLOCKLEN - 1;
-
- for (index = indexlo; index <= indexhi; ++index) {
+ for (b = deque->leftblock; b != deque->rightblock; b = b->rightlink) {
+ for (index = indexlo; index < BLOCKLEN ; index++) {
item = b->data[index];
Py_VISIT(item);
}
indexlo = 0;
}
+ for (index = indexlo; index <= deque->rightindex; index++) {
+ item = b->data[index];
+ Py_VISIT(item);
+ }
return 0;
}