diff --git a/ChangeLog b/ChangeLog index a23dabce53..6ba3c7b6cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Mon Jul 16 14:14:21 2012 Tanaka Akira + + * bignum.c (enum big_op_t): new type. + (big_op): use enum big_op_t. + (big_gt): ditto. + (big_ge): ditto. + (big_lt): ditto. + (big_le): ditto. + Sat Jul 14 18:18:48 2012 Nobuyoshi Nakada * array.c (rb_get_values_at): fill with nil out of range. diff --git a/bignum.c b/bignum.c index d658ce88e1..43669db4a7 100644 --- a/bignum.c +++ b/bignum.c @@ -1487,8 +1487,15 @@ rb_big_cmp(VALUE x, VALUE y) (RBIGNUM_SIGN(x) ? INT2FIX(-1) : INT2FIX(1)); } +enum big_op_t { + big_op_gt, + big_op_ge, + big_op_lt, + big_op_le +}; + static VALUE -big_op(VALUE x, VALUE y, int op) +big_op(VALUE x, VALUE y, enum big_op_t op) { VALUE rel; int n; @@ -1516,10 +1523,10 @@ big_op(VALUE x, VALUE y, int op) { ID id = 0; switch (op) { - case 0: id = '>'; break; - case 1: id = rb_intern(">="); break; - case 2: id = '<'; break; - case 3: id = rb_intern("<="); break; + case big_op_gt: id = '>'; break; + case big_op_ge: id = rb_intern(">="); break; + case big_op_lt: id = '<'; break; + case big_op_le: id = rb_intern("<="); break; } return rb_num_coerce_relop(x, y, id); } @@ -1529,10 +1536,10 @@ big_op(VALUE x, VALUE y, int op) n = FIX2INT(rel); switch (op) { - case 0: return n > 0 ? Qtrue : Qfalse; - case 1: return n >= 0 ? Qtrue : Qfalse; - case 2: return n < 0 ? Qtrue : Qfalse; - case 3: return n <= 0 ? Qtrue : Qfalse; + case big_op_gt: return n > 0 ? Qtrue : Qfalse; + case big_op_ge: return n >= 0 ? Qtrue : Qfalse; + case big_op_lt: return n < 0 ? Qtrue : Qfalse; + case big_op_le: return n <= 0 ? Qtrue : Qfalse; } return Qundef; } @@ -1548,7 +1555,7 @@ big_op(VALUE x, VALUE y, int op) static VALUE big_gt(VALUE x, VALUE y) { - return big_op(x, y, 0); + return big_op(x, y, big_op_gt); } /* @@ -1562,7 +1569,7 @@ big_gt(VALUE x, VALUE y) static VALUE big_ge(VALUE x, VALUE y) { - return big_op(x, y, 1); + return big_op(x, y, big_op_ge); } /* @@ -1576,7 +1583,7 @@ big_ge(VALUE x, VALUE y) static VALUE big_lt(VALUE x, VALUE y) { - return big_op(x, y, 2); + return big_op(x, y, big_op_lt); } /* @@ -1590,7 +1597,7 @@ big_lt(VALUE x, VALUE y) static VALUE big_le(VALUE x, VALUE y) { - return big_op(x, y, 3); + return big_op(x, y, big_op_le); } /*