Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bd5f0e8

Browse files
committed
Hoist constant expression out of the inner loop.
1 parent 5098b58 commit bd5f0e8

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Python/bltinmodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,19 +469,19 @@ filter_next(filterobject *lz)
469469
PyObject *it = lz->it;
470470
long ok;
471471
PyObject *(*iternext)(PyObject *);
472+
int checktrue = lz->func == Py_None || lz->func == (PyObject *)&PyBool_Type;
472473

473474
iternext = *Py_TYPE(it)->tp_iternext;
474475
for (;;) {
475476
item = iternext(it);
476477
if (item == NULL)
477478
return NULL;
478479

479-
if (lz->func == Py_None || lz->func == (PyObject *)&PyBool_Type) {
480+
if (checktrue) {
480481
ok = PyObject_IsTrue(item);
481482
} else {
482483
PyObject *good;
483-
good = PyObject_CallFunctionObjArgs(lz->func,
484-
item, NULL);
484+
good = PyObject_CallFunctionObjArgs(lz->func, item, NULL);
485485
if (good == NULL) {
486486
Py_DECREF(item);
487487
return NULL;

0 commit comments

Comments
 (0)