ruby-changes:42103
From: mrkn <ko1@a...>
Date: Fri, 18 Mar 2016 22:11:19 +0900 (JST)
Subject: [ruby-changes:42103] mrkn:r54177 (trunk): * bignum.c (Bignum#eql?): remove its definition because it is unified
mrkn 2016-03-18 22:11:09 +0900 (Fri, 18 Mar 2016) New Revision: 54177 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54177 Log: * bignum.c (Bignum#eql?): remove its definition because it is unified with Numeric#eql?. * numeric.c (num_eql): treat Bignum values directly. Modified files: trunk/ChangeLog trunk/bignum.c trunk/numeric.c Index: numeric.c =================================================================== --- numeric.c (revision 54176) +++ numeric.c (revision 54177) @@ -1112,11 +1112,13 @@ flo_pow(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1112 * num.eql?(numeric) -> true or false * * Returns +true+ if +num+ and +numeric+ are the same type and have equal - * values. + * values. Contrast this with <code>Numeric#==</code>, 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) https://github.com/ruby/ruby/blob/trunk/numeric.c#L1126 { 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); } Index: bignum.c =================================================================== --- bignum.c (revision 54176) +++ bignum.c (revision 54177) @@ -5466,17 +5466,6 @@ rb_big_eq(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/bignum.c#L5466 return Qtrue; } -/* - * call-seq: - * big.eql?(obj) -> true or false - * - * Returns <code>true</code> only if <i>obj</i> is a - * <code>Bignum</code> with the same value as <i>big</i>. Contrast this - * with <code>Bignum#==</code>, which performs type conversions. - * - * 68719476736.eql?(68719476736.0) #=> false - */ - VALUE rb_big_eql(VALUE x, VALUE y) { @@ -7044,7 +7033,6 @@ Init_Bignum(void) https://github.com/ruby/ruby/blob/trunk/bignum.c#L7033 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); Index: ChangeLog =================================================================== --- ChangeLog (revision 54176) +++ ChangeLog (revision 54177) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Mar 18 22:10:00 2016 Kenta Murata <mrkn@m...> + + * 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 <mrkn@m...> * bignum.c (rb_big_to_s, Bignum#to_s): remove its definition because -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/