From: Raymond Hettinger Date: Wed, 4 Nov 2015 03:00:26 +0000 (-0500) Subject: Neaten-up the inner-loop logic. X-Git-Tag: v3.6.0a1~1129 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a91d2138199d28cd906997854cc4632f156bb05;p=python Neaten-up the inner-loop logic. --- diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 1ca6c72d37..0e594703d0 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -1053,13 +1053,13 @@ deque_index(dequeobject *deque, PyObject *args) } } - n = stop - i; - while (n--) { + n = stop - i + 1; + while (--n) { CHECK_NOT_END(b); item = b->data[index]; cmp = PyObject_RichCompareBool(item, v, Py_EQ); if (cmp > 0) - return PyLong_FromSsize_t(stop - (n + 1)); + return PyLong_FromSsize_t(stop - n); if (cmp < 0) return NULL; if (start_state != deque->state) {