summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorHai Shi <shihai1992@gmail.com>2020-06-07 12:05:36 (GMT)
committerGitHub <noreply@github.com>2020-06-07 12:05:36 (GMT)
commit47a23fc63fa5df2da8dbc542e78e521d4a7f10c9 (patch)
tree672aa7892961efc225df0d3949ccb036cc7fe9d9 /Modules
parentb8867e5d5aca33511942632b5f4e359b9245b2fa (diff)
downloadcpython-47a23fc63fa5df2da8dbc542e78e521d4a7f10c9.zip
cpython-47a23fc63fa5df2da8dbc542e78e521d4a7f10c9.tar.gz
cpython-47a23fc63fa5df2da8dbc542e78e521d4a7f10c9.tar.bz2
bpo-40898: Remove redundant if statements in tp_traverse (GH-20692)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_functoolsmodule.c3
-rw-r--r--Modules/_io/_iomodule.c4
-rw-r--r--Modules/itertoolsmodule.c3
-rw-r--r--Modules/overlapped.c8
4 files changed, 5 insertions, 13 deletions
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index d158d3b..f1ee23f 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -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;
}
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c
index a55e5ca..e430352 100644
--- a/Modules/_io/_iomodule.c
+++ b/Modules/_io/_iomodule.c
@@ -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;
}
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index 18fcebd..3f2f716 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -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;
}
diff --git a/Modules/overlapped.c b/Modules/overlapped.c
index df6282c..eed8fbf 100644
--- a/Modules/overlapped.c
+++ b/Modules/overlapped.c
@@ -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;
}