cleanup traverse_shared
This commit is contained in:
parent
3004f2106c
commit
37902d38f7
|
@ -44,36 +44,36 @@ static void
|
||||||
traverse_shared(struct writer_control *p, pic_value obj)
|
traverse_shared(struct writer_control *p, pic_value obj)
|
||||||
{
|
{
|
||||||
pic_state *pic = p->pic;
|
pic_state *pic = p->pic;
|
||||||
khash_t(l) *h = &p->labels;
|
|
||||||
khiter_t it;
|
|
||||||
size_t i;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
switch (pic_type(obj)) {
|
switch (pic_type(obj)) {
|
||||||
case PIC_TT_PAIR:
|
case PIC_TT_PAIR:
|
||||||
case PIC_TT_VECTOR:
|
case PIC_TT_VECTOR: {
|
||||||
it = kh_put(l, h, pic_obj_ptr(obj), &ret);
|
khash_t(l) *h = &p->labels;
|
||||||
if (ret != 0) {
|
khiter_t it;
|
||||||
kh_val(h, it) = -1;
|
int ret;
|
||||||
}
|
|
||||||
else if (kh_val(h, it) == -1) {
|
|
||||||
kh_val(h, it) = p->cnt++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pic_pair_p(obj)) {
|
it = kh_put(l, h, pic_ptr(obj), &ret);
|
||||||
traverse_shared(p, pic_car(p->pic, obj));
|
if (ret != 0) {
|
||||||
traverse_shared(p, pic_cdr(p->pic, obj));
|
/* first time */
|
||||||
}
|
kh_val(h, it) = -1;
|
||||||
else {
|
|
||||||
for (i = 0; i < pic_vec_ptr(obj)->len; ++i) {
|
if (pic_pair_p(obj)) {
|
||||||
traverse_shared(p, pic_vec_ptr(obj)->data[i]);
|
/* pair */
|
||||||
|
traverse_shared(p, pic_car(pic, obj));
|
||||||
|
traverse_shared(p, pic_cdr(pic, obj));
|
||||||
|
} else {
|
||||||
|
/* vector */
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < pic_vec_ptr(obj)->len; ++i) {
|
||||||
|
traverse_shared(p, pic_vec_ptr(obj)->data[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else if (kh_val(h, it) == -1) {
|
||||||
|
/* second time */
|
||||||
|
kh_val(h, it) = p->cnt++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
/* pass */
|
/* pass */
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue