diff options
author | Raymond Hettinger <python@rcn.com> | 2015-10-09 05:34:08 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-10-09 05:34:08 (GMT) |
commit | bd5f0e8c1cf633a238c10e1d3199c0d572a4df1d (patch) | |
tree | cbce88d841e73702e17f87cee452ecf4ace8da85 /Python/bltinmodule.c | |
parent | 5098b58381e572ccd55982004da903a59ffec95c (diff) | |
download | cpython-bd5f0e8c1cf633a238c10e1d3199c0d572a4df1d.zip cpython-bd5f0e8c1cf633a238c10e1d3199c0d572a4df1d.tar.gz cpython-bd5f0e8c1cf633a238c10e1d3199c0d572a4df1d.tar.bz2 |
Hoist constant expression out of the inner loop.
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 3f2e2c0..3c8f1e9 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -469,6 +469,7 @@ filter_next(filterobject *lz) PyObject *it = lz->it; long ok; PyObject *(*iternext)(PyObject *); + int checktrue = lz->func == Py_None || lz->func == (PyObject *)&PyBool_Type; iternext = *Py_TYPE(it)->tp_iternext; for (;;) { @@ -476,12 +477,11 @@ filter_next(filterobject *lz) if (item == NULL) return NULL; - if (lz->func == Py_None || lz->func == (PyObject *)&PyBool_Type) { + if (checktrue) { ok = PyObject_IsTrue(item); } else { PyObject *good; - good = PyObject_CallFunctionObjArgs(lz->func, - item, NULL); + good = PyObject_CallFunctionObjArgs(lz->func, item, NULL); if (good == NULL) { Py_DECREF(item); return NULL; |