Skip to content

Commit 47a23fc

Browse files
authored
bpo-40898: Remove redundant if statements in tp_traverse (GH-20692)
1 parent b8867e5 commit 47a23fc

File tree

4 files changed

+5
-13
lines changed

4 files changed

+5
-13
lines changed

Modules/_functoolsmodule.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,7 @@ static int
484484
keyobject_traverse(keyobject *ko, visitproc visit, void *arg)
485485
{
486486
Py_VISIT(ko->cmp);
487-
if (ko->object)
488-
Py_VISIT(ko->object);
487+
Py_VISIT(ko->object);
489488
return 0;
490489
}
491490

Modules/_io/_iomodule.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,9 +623,7 @@ iomodule_traverse(PyObject *mod, visitproc visit, void *arg) {
623623
_PyIO_State *state = get_io_state(mod);
624624
if (!state->initialized)
625625
return 0;
626-
if (state->locale_module != NULL) {
627-
Py_VISIT(state->locale_module);
628-
}
626+
Py_VISIT(state->locale_module);
629627
Py_VISIT(state->unsupported_operation);
630628
return 0;
631629
}

Modules/itertoolsmodule.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -999,8 +999,7 @@ cycle_dealloc(cycleobject *lz)
999999
static int
10001000
cycle_traverse(cycleobject *lz, visitproc visit, void *arg)
10011001
{
1002-
if (lz->it)
1003-
Py_VISIT(lz->it);
1002+
Py_VISIT(lz->it);
10041003
Py_VISIT(lz->saved);
10051004
return 0;
10061005
}

Modules/overlapped.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,12 +1504,8 @@ Overlapped_traverse(OverlappedObject *self, visitproc visit, void *arg)
15041504
}
15051505
break;
15061506
case TYPE_READ_FROM:
1507-
if(self->read_from.result) {
1508-
Py_VISIT(self->read_from.result);
1509-
}
1510-
if(self->read_from.allocated_buffer) {
1511-
Py_VISIT(self->read_from.allocated_buffer);
1512-
}
1507+
Py_VISIT(self->read_from.result);
1508+
Py_VISIT(self->read_from.allocated_buffer);
15131509
}
15141510
return 0;
15151511
}

0 commit comments

Comments
 (0)