summaryrefslogtreecommitdiff
path: root/complex.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-15 06:28:05 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-15 06:28:05 +0000
commitc4e660457fb893a248ecec64eec3b8e68a990992 (patch)
tree4853c4c4d15e0b451b1a04caace35466117a4b9b /complex.c
parent6394b63db9abe34234e7420ef69b3e55ba19260e (diff)
complex.c: purge id_eqeq_p and limit return value
* complex.c (f_eqeq_p): use rb_equal. * complex.c (nucomp_eqeq_p): limit return value to true or false, instead of the result of the other as-is. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
-rw-r--r--complex.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/complex.c b/complex.c
index f6fc6eef19..5b5f17edfa 100644
--- a/complex.c
+++ b/complex.c
@@ -31,7 +31,7 @@ static VALUE nucomp_abs(VALUE self);
static VALUE nucomp_arg(VALUE self);
static ID id_abs, id_arg, id_convert,
- id_denominator, id_eqeq_p, id_expt, id_fdiv,
+ id_denominator, id_expt, id_fdiv,
id_negate, id_numerator, id_quo,
id_real_p, id_to_f, id_to_i, id_to_r,
id_i_real, id_i_imag,
@@ -165,12 +165,14 @@ f_to_f(VALUE x)
fun1(to_r)
-inline static VALUE
+inline static int
f_eqeq_p(VALUE x, VALUE y)
{
if (FIXNUM_P(x) && FIXNUM_P(y))
- return f_boolcast(x == y);
- return rb_funcall(x, id_eqeq_p, 1, y);
+ return x == y;
+ else if (RB_FLOAT_TYPE_P(x) || RB_FLOAT_TYPE_P(y))
+ return NUM2DBL(x) == NUM2DBL(y);
+ return (int)rb_equal(x, y);
}
fun2(expt)
@@ -965,7 +967,7 @@ nucomp_eqeq_p(VALUE self, VALUE other)
return f_boolcast(f_eqeq_p(dat->real, other) && f_zero_p(dat->imag));
}
- return f_eqeq_p(other, self);
+ return f_boolcast(f_eqeq_p(other, self));
}
/* :nodoc: */
@@ -2149,7 +2151,6 @@ Init_Complex(void)
id_arg = rb_intern("arg");
id_convert = rb_intern("convert");
id_denominator = rb_intern("denominator");
- id_eqeq_p = rb_intern("==");
id_expt = rb_intern("**");
id_fdiv = rb_intern("fdiv");
id_negate = rb_intern("-@");