Skip to content

Commit

Permalink
bpo-40898: Remove redundant if statements in tp_traverse (GH-20692)
Browse files Browse the repository at this point in the history
  • Loading branch information
shihai1991 committed Jun 7, 2020
1 parent b8867e5 commit 47a23fc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
3 changes: 1 addition & 2 deletions Modules/_functoolsmodule.c
Expand Up @@ -484,8 +484,7 @@ static int
keyobject_traverse(keyobject *ko, visitproc visit, void *arg)
{
Py_VISIT(ko->cmp);
if (ko->object)
Py_VISIT(ko->object);
Py_VISIT(ko->object);
return 0;
}

Expand Down
4 changes: 1 addition & 3 deletions Modules/_io/_iomodule.c
Expand Up @@ -623,9 +623,7 @@ iomodule_traverse(PyObject *mod, visitproc visit, void *arg) {
_PyIO_State *state = get_io_state(mod);
if (!state->initialized)
return 0;
if (state->locale_module != NULL) {
Py_VISIT(state->locale_module);
}
Py_VISIT(state->locale_module);
Py_VISIT(state->unsupported_operation);
return 0;
}
Expand Down
3 changes: 1 addition & 2 deletions Modules/itertoolsmodule.c
Expand Up @@ -999,8 +999,7 @@ cycle_dealloc(cycleobject *lz)
static int
cycle_traverse(cycleobject *lz, visitproc visit, void *arg)
{
if (lz->it)
Py_VISIT(lz->it);
Py_VISIT(lz->it);
Py_VISIT(lz->saved);
return 0;
}
Expand Down
8 changes: 2 additions & 6 deletions Modules/overlapped.c
Expand Up @@ -1504,12 +1504,8 @@ Overlapped_traverse(OverlappedObject *self, visitproc visit, void *arg)
}
break;
case TYPE_READ_FROM:
if(self->read_from.result) {
Py_VISIT(self->read_from.result);
}
if(self->read_from.allocated_buffer) {
Py_VISIT(self->read_from.allocated_buffer);
}
Py_VISIT(self->read_from.result);
Py_VISIT(self->read_from.allocated_buffer);
}
return 0;
}
Expand Down

0 comments on commit 47a23fc

Please sign in to comment.