From 2b0d646b751e6e5bdb466c05ffd2824dd46c7d60 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Wed, 23 Sep 2015 19:15:44 -0700 Subject: Replace an unpredictable branch with a simple addition. --- Modules/_collectionsmodule.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index be6c90c..8d753c3 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -852,10 +852,9 @@ deque_count(dequeobject *deque, PyObject *v) CHECK_NOT_END(b); item = b->data[index]; cmp = PyObject_RichCompareBool(item, v, Py_EQ); - if (cmp > 0) - count++; - else if (cmp < 0) + if (cmp < 0) return NULL; + count += cmp; if (start_state != deque->state) { PyErr_SetString(PyExc_RuntimeError, -- cgit v0.12