more style fixes

This commit is contained in:
Yuichi Nishiwaki 2014-07-19 12:11:49 +09:00
parent a2f628d240
commit d295653d20
1 changed files with 12 additions and 15 deletions

View File

@ -34,8 +34,6 @@ pic_blob_equal_p(struct pic_blob *blob1, struct pic_blob *blob2)
static bool static bool
pic_internal_equal_p(pic_state *pic, pic_value x, pic_value y, size_t depth, xhash *ht) pic_internal_equal_p(pic_state *pic, pic_value x, pic_value y, size_t depth, xhash *ht)
{ {
xh_entry *e;
enum pic_tt type;
pic_value local = pic_nil_value(); pic_value local = pic_nil_value();
size_t rapid_count = 0; size_t rapid_count = 0;
@ -48,15 +46,12 @@ pic_internal_equal_p(pic_state *pic, pic_value x, pic_value y, size_t depth, xha
} }
switch (pic_type(x)) { switch (pic_type(x)) {
case PIC_TT_PAIR: case PIC_TT_PAIR:
case PIC_TT_VECTOR: { case PIC_TT_VECTOR:
e = xh_get(ht, pic_obj_ptr(x)); if (xh_get(ht, pic_obj_ptr(x)) != NULL) {
if (e) { return true; /* `x' was seen already. */
/* `x' was seen already. */
return true;
} else { } else {
xh_put(ht, pic_obj_ptr(x), NULL); xh_put(ht, pic_obj_ptr(x), NULL);
} }
}
default: default:
break; break;
} }
@ -67,13 +62,10 @@ pic_internal_equal_p(pic_state *pic, pic_value x, pic_value y, size_t depth, xha
if (pic_eqv_p(x, y)) if (pic_eqv_p(x, y))
return true; return true;
type = pic_type(x); if (pic_type(x) != pic_type(y))
if (type != pic_type(y)) {
return false; return false;
}
switch (type) { switch (pic_type(x)) {
case PIC_TT_PAIR: case PIC_TT_PAIR:
if (pic_nil_p(local)) { if (pic_nil_p(local)) {
local = x; local = x;
@ -81,6 +73,7 @@ pic_internal_equal_p(pic_state *pic, pic_value x, pic_value y, size_t depth, xha
if (pic_internal_equal_p(pic, pic_car(pic, x), pic_car(pic, y), depth + 1, ht)) { if (pic_internal_equal_p(pic, pic_car(pic, x), pic_car(pic, y), depth + 1, ht)) {
x = pic_cdr(pic, x); x = pic_cdr(pic, x);
y = pic_cdr(pic, y); y = pic_cdr(pic, y);
++rapid_count; ++rapid_count;
if (rapid_count == 2) { if (rapid_count == 2) {
@ -91,7 +84,7 @@ pic_internal_equal_p(pic_state *pic, pic_value x, pic_value y, size_t depth, xha
} }
} }
goto LOOP; goto LOOP;
}else{ } else {
return false; return false;
} }
case PIC_TT_BLOB: { case PIC_TT_BLOB: {
@ -109,7 +102,10 @@ pic_internal_equal_p(pic_state *pic, pic_value x, pic_value y, size_t depth, xha
} }
case PIC_TT_VECTOR: { case PIC_TT_VECTOR: {
size_t i; size_t i;
struct pic_vector *u = pic_vec_ptr(x), *v = pic_vec_ptr(y); struct pic_vector *u, *v;
u = pic_vec_ptr(x);
v = pic_vec_ptr(y);
if (u->len != v->len) { if (u->len != v->len) {
return false; return false;
@ -130,6 +126,7 @@ pic_internal_equal_p(pic_state *pic, pic_value x, pic_value y, size_t depth, xha
bool bool
pic_equal_p(pic_state *pic, pic_value x, pic_value y){ pic_equal_p(pic_state *pic, pic_value x, pic_value y){
xhash ht; xhash ht;
xh_init_ptr(&ht, 0); xh_init_ptr(&ht, 0);
return pic_internal_equal_p(pic, x, y, 0, &ht); return pic_internal_equal_p(pic, x, y, 0, &ht);
} }