aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-13 01:51:29 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-13 01:51:29 +0000
commit99d8c77e18d7a8250e10d07a9e36c1db042babec (patch)
tree7d9e51232aec5ed0576b052cfae52318cca6c86b
parentb2634a7ac207a230444fa9433b2ec91847bf3a95 (diff)
downloadruby-99d8c77e18d7a8250e10d07a9e36c1db042babec.tar.gz
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
-rw-r--r--rational.c13
1 files 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("-@");