From 18d114eff2167e15f072fd1ca42d573b039a9093 Mon Sep 17 00:00:00 2001 From: mrkn Date: Fri, 18 Mar 2016 13:11:09 +0000 Subject: * bignum.c (Bignum#eql?): remove its definition because it is unified with Numeric#eql?. * numeric.c (num_eql): treat Bignum values directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ bignum.c | 12 ------------ numeric.c | 8 +++++++- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index d6dd21bb05..f393c989ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Mar 18 22:10:00 2016 Kenta Murata + + * bignum.c (Bignum#eql?): remove its definition because it is unified + with Numeric#eql?. + + * numeric.c (num_eql): treat Bignum values directly. + Fri Mar 18 21:57:00 2016 Kenta Murata * bignum.c (rb_big_to_s, Bignum#to_s): remove its definition because diff --git a/bignum.c b/bignum.c index e46c18837e..67f8179271 100644 --- a/bignum.c +++ b/bignum.c @@ -5466,17 +5466,6 @@ rb_big_eq(VALUE x, VALUE y) return Qtrue; } -/* - * call-seq: - * big.eql?(obj) -> true or false - * - * Returns true only if obj is a - * Bignum with the same value as big. Contrast this - * with Bignum#==, which performs type conversions. - * - * 68719476736.eql?(68719476736.0) #=> false - */ - VALUE rb_big_eql(VALUE x, VALUE y) { @@ -7044,7 +7033,6 @@ Init_Bignum(void) rb_define_method(rb_cBignum, "<", big_lt, 1); rb_define_method(rb_cBignum, "<=", big_le, 1); rb_define_method(rb_cBignum, "===", rb_big_eq, 1); - rb_define_method(rb_cBignum, "eql?", rb_big_eql, 1); rb_define_method(rb_cBignum, "to_f", rb_big_to_f, 0); rb_define_method(rb_cBignum, "abs", rb_big_abs, 0); rb_define_method(rb_cBignum, "magnitude", rb_big_abs, 0); diff --git a/numeric.c b/numeric.c index ba174f0104..fc2a514201 100644 --- a/numeric.c +++ b/numeric.c @@ -1112,11 +1112,13 @@ flo_pow(VALUE x, VALUE y) * num.eql?(numeric) -> true or false * * Returns +true+ if +num+ and +numeric+ are the same type and have equal - * values. + * values. Contrast this with Numeric#==, which performs + * type conversions. * * 1 == 1.0 #=> true * 1.eql?(1.0) #=> false * (1.0).eql?(1.0) #=> true + * 68719476736.eql?(68719476736.0) #=> false */ static VALUE @@ -1124,6 +1126,10 @@ num_eql(VALUE x, VALUE y) { if (TYPE(x) != TYPE(y)) return Qfalse; + if (RB_TYPE_P(x, T_BIGNUM)) { + return rb_big_eql(x, y); + } + return rb_equal(x, y); } -- cgit v1.2.3