From 97803e22509545f224ab6480ed5220f73b28f9f9 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 13 Nov 2016 01:51:29 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- rational.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/rational.c b/rational.c index cd71fb4f2f..f8adafe1e0 100644 --- a/rational.c +++ b/rational.c @@ -33,7 +33,7 @@ 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) { 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) 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) 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) 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) } } else { - return rb_funcall(other, id_eqeq_p, 1, self); + return rb_equal(other, self); } } @@ -2593,7 +2593,6 @@ Init_Rational(void) 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("-@");