diff options
Diffstat (limited to 'mrbgems/mruby-struct/src/struct.c')
| -rw-r--r-- | mrbgems/mruby-struct/src/struct.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/mrbgems/mruby-struct/src/struct.c b/mrbgems/mruby-struct/src/struct.c index 1f3ae290f..28ba9c3db 100644 --- a/mrbgems/mruby-struct/src/struct.c +++ b/mrbgems/mruby-struct/src/struct.c @@ -659,34 +659,28 @@ mrb_struct_eql(mrb_state *mrb, mrb_value s) mrb_value s2; mrb_value *ptr, *ptr2; mrb_int i, len; - mrb_bool eql_p; mrb_get_args(mrb, "o", &s2); if (mrb_obj_equal(mrb, s, s2)) { - eql_p = 1; + return mrb_true_value(); } - else if (strcmp(mrb_class_name(mrb, mrb_obj_class(mrb, s2)), "Struct") || - mrb_obj_class(mrb, s) != mrb_obj_class(mrb, s2)) { - eql_p = 0; + if (strcmp(mrb_class_name(mrb, mrb_obj_class(mrb, s2)), "Struct") || + mrb_obj_class(mrb, s) != mrb_obj_class(mrb, s2)) { + return mrb_false_value(); } - else if (RSTRUCT_LEN(s) != RSTRUCT_LEN(s2)) { + if (RSTRUCT_LEN(s) != RSTRUCT_LEN(s2)) { mrb_bug(mrb, "inconsistent struct"); /* should never happen */ - eql_p = 0; /* This substuture is just to suppress warnings. never called. */ } - else { - ptr = RSTRUCT_PTR(s); - ptr2 = RSTRUCT_PTR(s2); - len = RSTRUCT_LEN(s); - eql_p = 1; - for (i=0; i<len; i++) { - if (!mrb_eql(mrb, ptr[i], ptr2[i])) { - eql_p = 0; - break; - } + ptr = RSTRUCT_PTR(s); + ptr2 = RSTRUCT_PTR(s2); + len = RSTRUCT_LEN(s); + for (i=0; i<len; i++) { + if (!mrb_eql(mrb, ptr[i], ptr2[i])) { + return mrb_false_value(); } } - return mrb_bool_value(eql_p); + return mrb_true_value(); } /* |
