ruby-changes:44690
From: nobu <ko1@a...>
Date: Sun, 13 Nov 2016 10:51:35 +0900 (JST)
Subject: [ruby-changes:44690] nobu:r56763 (trunk): purge id_eqeq_p
nobu 2016-11-13 10:51:29 +0900 (Sun, 13 Nov 2016) New Revision: 56763 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56763 Log: purge id_eqeq_p * rational.c (f_{eqeq,zero,one,minus_one}_p, nurat_eqeq_p): use rb_equal. this function returns Qtrue or Qfalse always, so it is safe to cast down to int. Modified files: trunk/rational.c Index: rational.c =================================================================== --- rational.c (revision 56762) +++ rational.c (revision 56763) @@ -33,7 +33,7 @@ https://github.com/ruby/ruby/blob/trunk/rational.c#L33 VALUE rb_cRational; -static ID id_abs, id_eqeq_p, id_idiv, id_integer_p, id_negate, id_to_i, +static ID id_abs, id_idiv, id_integer_p, id_negate, id_to_i, id_i_num, id_i_den; #define f_boolcast(x) ((x) ? Qtrue : Qfalse) @@ -153,7 +153,7 @@ f_eqeq_p(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/rational.c#L153 { if (FIXNUM_P(x) && FIXNUM_P(y)) return x == y; - return RTEST(rb_funcall(x, id_eqeq_p, 1, y)); + return (int)rb_equal(x, y); } fun2(idiv) @@ -171,7 +171,7 @@ f_zero_p(VALUE x) https://github.com/ruby/ruby/blob/trunk/rational.c#L171 return FIXNUM_ZERO_P(num); } - return RTEST(rb_funcall(x, id_eqeq_p, 1, ZERO)); + return (int)rb_equal(x, ZERO); } #define f_nonzero_p(x) (!f_zero_p(x)) @@ -188,7 +188,7 @@ f_one_p(VALUE x) https://github.com/ruby/ruby/blob/trunk/rational.c#L188 return num == LONG2FIX(1) && den == LONG2FIX(1); } - return RTEST(rb_funcall(x, id_eqeq_p, 1, ONE)); + return (int)rb_equal(x, ONE); } inline static int @@ -206,7 +206,7 @@ f_minus_one_p(VALUE x) https://github.com/ruby/ruby/blob/trunk/rational.c#L206 return num == LONG2FIX(-1) && den == LONG2FIX(1); } - return RTEST(rb_funcall(x, id_eqeq_p, 1, INT2FIX(-1))); + return (int)rb_equal(x, INT2FIX(-1)); } inline static int @@ -1147,7 +1147,7 @@ nurat_eqeq_p(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/rational.c#L1147 } } else { - return rb_funcall(other, id_eqeq_p, 1, self); + return rb_equal(other, self); } } @@ -2593,7 +2593,6 @@ Init_Rational(void) https://github.com/ruby/ruby/blob/trunk/rational.c#L2593 assert(fprintf(stderr, "assert() is now active\n")); id_abs = rb_intern("abs"); - id_eqeq_p = rb_intern("=="); id_idiv = rb_intern("div"); id_integer_p = rb_intern("integer?"); id_negate = rb_intern("-@"); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/