Commit bd9adab1 authored by Raymond Hettinger's avatar Raymond Hettinger

Micro-optimization for list_contains. Factored double if test

out of the loop.
parent aae5999b
......@@ -263,14 +263,13 @@ tuplecontains(PyTupleObject *a, PyObject *el)
{
int i, cmp;
for (i = 0; i < a->ob_size; ++i) {
for (i = 0, cmp = 0 ; cmp == 0 && i < a->ob_size; ++i)
cmp = PyObject_RichCompareBool(el, PyTuple_GET_ITEM(a, i),
Py_EQ);
if (cmp > 0)
return 1;
else if (cmp < 0)
return -1;
}
Py_EQ);
if (cmp > 0)
return 1;
if (cmp < 0)
return -1;
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment