summaryrefslogtreecommitdiffstats
path: root/Modules/_collectionsmodule.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2013-07-06 19:07:06 (GMT)
committerRaymond Hettinger <python@rcn.com>2013-07-06 19:07:06 (GMT)
commit98054b4c1be933f5bbfb3c1a1f4ee3f556dd47ca (patch)
tree2335eadb87829ca0d36ab330691b6f4f996f92fa /Modules/_collectionsmodule.c
parent0075110ab2b2f514484b9a0dcfc229fb23e08ac7 (diff)
downloadcpython-98054b4c1be933f5bbfb3c1a1f4ee3f556dd47ca.zip
cpython-98054b4c1be933f5bbfb3c1a1f4ee3f556dd47ca.tar.gz
cpython-98054b4c1be933f5bbfb3c1a1f4ee3f556dd47ca.tar.bz2
Remove unnecessary branches from count() and reverse().
Diffstat (limited to 'Modules/_collectionsmodule.c')
-rw-r--r--Modules/_collectionsmodule.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 781949d..376a8e6 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -551,6 +551,8 @@ deque_reverse(dequeobject *deque, PyObject *unused)
for (i=0 ; i<n ; i++) {
/* Validate that pointers haven't met in the middle */
assert(leftblock != rightblock || leftindex < rightindex);
+ assert(leftblock != NULL);
+ assert(rightblock != NULL);
/* Swap */
tmp = leftblock->data[leftindex];
@@ -560,8 +562,6 @@ deque_reverse(dequeobject *deque, PyObject *unused)
/* Advance left block/index pair */
leftindex++;
if (leftindex == BLOCKLEN) {
- if (leftblock->rightlink == NULL)
- break;
leftblock = leftblock->rightlink;
leftindex = 0;
}
@@ -569,8 +569,6 @@ deque_reverse(dequeobject *deque, PyObject *unused)
/* Step backwards with the right block/index pair */
rightindex--;
if (rightindex == -1) {
- if (rightblock->leftlink == NULL)
- break;
rightblock = rightblock->leftlink;
rightindex = BLOCKLEN - 1;
}
@@ -594,6 +592,7 @@ deque_count(dequeobject *deque, PyObject *v)
int cmp;
for (i=0 ; i<n ; i++) {
+ assert(leftblock != NULL);
item = leftblock->data[leftindex];
cmp = PyObject_RichCompareBool(item, v, Py_EQ);
if (cmp > 0)
@@ -610,8 +609,6 @@ deque_count(dequeobject *deque, PyObject *v)
/* Advance left block/index pair */
leftindex++;
if (leftindex == BLOCKLEN) {
- if (leftblock->rightlink == NULL) /* can occur when i==n-1 */
- break;
leftblock = leftblock->rightlink;
leftindex = 0;
}