Exercise Jim's VISIT macro.

This commit is contained in:
Raymond Hettinger 2004-07-15 05:32:47 +00:00
parent 8aa23927e3
commit 58ed69b402
1 changed files with 24 additions and 129 deletions

View File

@ -64,33 +64,11 @@ groupby_dealloc(groupbyobject *gbo)
static int static int
groupby_traverse(groupbyobject *gbo, visitproc visit, void *arg) groupby_traverse(groupbyobject *gbo, visitproc visit, void *arg)
{ {
int err; Py_VISIT(gbo->it);
Py_VISIT(gbo->keyfunc);
if (gbo->it) { Py_VISIT(gbo->tgtkey);
err = visit(gbo->it, arg); Py_VISIT(gbo->currkey);
if (err) Py_VISIT(gbo->currvalue);
return err;
}
if (gbo->keyfunc) {
err = visit(gbo->keyfunc, arg);
if (err)
return err;
}
if (gbo->tgtkey) {
err = visit(gbo->tgtkey, arg);
if (err)
return err;
}
if (gbo->currkey) {
err = visit(gbo->currkey, arg);
if (err)
return err;
}
if (gbo->currvalue) {
err = visit(gbo->currvalue, arg);
if (err)
return err;
}
return 0; return 0;
} }
@ -671,18 +649,8 @@ cycle_dealloc(cycleobject *lz)
static int static int
cycle_traverse(cycleobject *lz, visitproc visit, void *arg) cycle_traverse(cycleobject *lz, visitproc visit, void *arg)
{ {
int err; Py_VISIT(lz->it);
Py_VISIT(lz->saved);
if (lz->it) {
err = visit(lz->it, arg);
if (err)
return err;
}
if (lz->saved) {
err = visit(lz->saved, arg);
if (err)
return err;
}
return 0; return 0;
} }
@ -820,18 +788,8 @@ dropwhile_dealloc(dropwhileobject *lz)
static int static int
dropwhile_traverse(dropwhileobject *lz, visitproc visit, void *arg) dropwhile_traverse(dropwhileobject *lz, visitproc visit, void *arg)
{ {
int err; Py_VISIT(lz->it);
Py_VISIT(lz->func);
if (lz->it) {
err = visit(lz->it, arg);
if (err)
return err;
}
if (lz->func) {
err = visit(lz->func, arg);
if (err)
return err;
}
return 0; return 0;
} }
@ -971,18 +929,8 @@ takewhile_dealloc(takewhileobject *lz)
static int static int
takewhile_traverse(takewhileobject *lz, visitproc visit, void *arg) takewhile_traverse(takewhileobject *lz, visitproc visit, void *arg)
{ {
int err; Py_VISIT(lz->it);
Py_VISIT(lz->func);
if (lz->it) {
err = visit(lz->it, arg);
if (err)
return err;
}
if (lz->func) {
err = visit(lz->func, arg);
if (err)
return err;
}
return 0; return 0;
} }
@ -1167,8 +1115,7 @@ islice_dealloc(isliceobject *lz)
static int static int
islice_traverse(isliceobject *lz, visitproc visit, void *arg) islice_traverse(isliceobject *lz, visitproc visit, void *arg)
{ {
if (lz->it) Py_VISIT(lz->it);
return visit(lz->it, arg);
return 0; return 0;
} }
@ -1309,18 +1256,8 @@ starmap_dealloc(starmapobject *lz)
static int static int
starmap_traverse(starmapobject *lz, visitproc visit, void *arg) starmap_traverse(starmapobject *lz, visitproc visit, void *arg)
{ {
int err; Py_VISIT(lz->it);
Py_VISIT(lz->func);
if (lz->it) {
err = visit(lz->it, arg);
if (err)
return err;
}
if (lz->func) {
err = visit(lz->func, arg);
if (err)
return err;
}
return 0; return 0;
} }
@ -1462,18 +1399,8 @@ imap_dealloc(imapobject *lz)
static int static int
imap_traverse(imapobject *lz, visitproc visit, void *arg) imap_traverse(imapobject *lz, visitproc visit, void *arg)
{ {
int err; Py_VISIT(lz->iters);
Py_VISIT(lz->func);
if (lz->iters) {
err = visit(lz->iters, arg);
if (err)
return err;
}
if (lz->func) {
err = visit(lz->func, arg);
if (err)
return err;
}
return 0; return 0;
} }
@ -1648,8 +1575,7 @@ chain_dealloc(chainobject *lz)
static int static int
chain_traverse(chainobject *lz, visitproc visit, void *arg) chain_traverse(chainobject *lz, visitproc visit, void *arg)
{ {
if (lz->ittuple) Py_VISIT(lz->ittuple);
return visit(lz->ittuple, arg);
return 0; return 0;
} }
@ -1778,18 +1704,8 @@ ifilter_dealloc(ifilterobject *lz)
static int static int
ifilter_traverse(ifilterobject *lz, visitproc visit, void *arg) ifilter_traverse(ifilterobject *lz, visitproc visit, void *arg)
{ {
int err; Py_VISIT(lz->it);
Py_VISIT(lz->func);
if (lz->it) {
err = visit(lz->it, arg);
if (err)
return err;
}
if (lz->func) {
err = visit(lz->func, arg);
if (err)
return err;
}
return 0; return 0;
} }
@ -1929,18 +1845,8 @@ ifilterfalse_dealloc(ifilterfalseobject *lz)
static int static int
ifilterfalse_traverse(ifilterfalseobject *lz, visitproc visit, void *arg) ifilterfalse_traverse(ifilterfalseobject *lz, visitproc visit, void *arg)
{ {
int err; Py_VISIT(lz->it);
Py_VISIT(lz->func);
if (lz->it) {
err = visit(lz->it, arg);
if (err)
return err;
}
if (lz->func) {
err = visit(lz->func, arg);
if (err)
return err;
}
return 0; return 0;
} }
@ -2199,18 +2105,8 @@ izip_dealloc(izipobject *lz)
static int static int
izip_traverse(izipobject *lz, visitproc visit, void *arg) izip_traverse(izipobject *lz, visitproc visit, void *arg)
{ {
int err; Py_VISIT(lz->ittuple);
Py_VISIT(lz->result);
if (lz->ittuple) {
err = visit(lz->ittuple, arg);
if (err)
return err;
}
if (lz->result) {
err = visit(lz->result, arg);
if (err)
return err;
}
return 0; return 0;
} }
@ -2357,8 +2253,7 @@ repeat_dealloc(repeatobject *ro)
static int static int
repeat_traverse(repeatobject *ro, visitproc visit, void *arg) repeat_traverse(repeatobject *ro, visitproc visit, void *arg)
{ {
if (ro->element) Py_VISIT(ro->element);
return visit(ro->element, arg);
return 0; return 0;
} }