mirror of https://github.com/python/cpython
Hoist constant expression out of the inner loop.
This commit is contained in:
parent
5098b58381
commit
bd5f0e8c1c
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue