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;
|
||||||
|
khiter_t it;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
it = kh_put(l, h, pic_ptr(obj), &ret);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
/* first time */
|
||||||
kh_val(h, it) = -1;
|
kh_val(h, it) = -1;
|
||||||
}
|
|
||||||
else if (kh_val(h, it) == -1) {
|
|
||||||
kh_val(h, it) = p->cnt++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pic_pair_p(obj)) {
|
if (pic_pair_p(obj)) {
|
||||||
traverse_shared(p, pic_car(p->pic, obj));
|
/* pair */
|
||||||
traverse_shared(p, pic_cdr(p->pic, obj));
|
traverse_shared(p, pic_car(pic, obj));
|
||||||
}
|
traverse_shared(p, pic_cdr(pic, obj));
|
||||||
else {
|
} else {
|
||||||
|
/* vector */
|
||||||
|
size_t i;
|
||||||
for (i = 0; i < pic_vec_ptr(obj)->len; ++i) {
|
for (i = 0; i < pic_vec_ptr(obj)->len; ++i) {
|
||||||
traverse_shared(p, pic_vec_ptr(obj)->data[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