1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2012-07-16 05:15:36 +00:00
parent 051799b674
commit 4cd00ffe2d
2 changed files with 29 additions and 13 deletions

View file

@ -1,3 +1,12 @@
Mon Jul 16 14:14:21 2012 Tanaka Akira <akr@fsij.org>
* 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 <nobu@ruby-lang.org>
* array.c (rb_get_values_at): fill with nil out of range.

View file

@ -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);
}
/*