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

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
This commit is contained in:
nobu 2016-11-15 06:28:05 +00:00
parent 6394b63db9
commit c4e660457f

View file

@ -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("-@");