ruby-changes:51452
From: nobu <ko1@a...>
Date: Thu, 14 Jun 2018 16:09:07 +0900 (JST)
Subject: [ruby-changes:51452] nobu:r63660 (trunk): bignum.c: get rid of redefined method
nobu 2018-06-14 16:09:02 +0900 (Thu, 14 Jun 2018) New Revision: 63660 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63660 Log: bignum.c: get rid of redefined method * bignum.c (int_pow_tmp3): get rid of redefined Integer#> on internal calculations, as well as the GMP version. * bignum.c (rb_int_powm): ditto. Modified files: trunk/bignum.c trunk/internal.h trunk/numeric.c Index: numeric.c =================================================================== --- numeric.c (revision 63659) +++ numeric.c (revision 63660) @@ -296,6 +296,18 @@ int_neg_p(VALUE num) https://github.com/ruby/ruby/blob/trunk/numeric.c#L296 } int +rb_int_positive_p(VALUE num) +{ + return int_pos_p(num); +} + +int +rb_int_negative_p(VALUE num) +{ + return int_neg_p(num); +} + +int rb_num_negative_p(VALUE num) { return rb_num_negative_int_p(num); Index: internal.h =================================================================== --- internal.h (revision 63659) +++ internal.h (revision 63660) @@ -1459,6 +1459,8 @@ VALUE rb_int_lshift(VALUE x, VALUE y); https://github.com/ruby/ruby/blob/trunk/internal.h#L1459 VALUE rb_int_div(VALUE x, VALUE y); VALUE rb_int_abs(VALUE num); VALUE rb_int_odd_p(VALUE num); +int rb_int_positive_p(VALUE num); +int rb_int_negative_p(VALUE num); static inline VALUE rb_num_compare_with_zero(VALUE num, ID mid) Index: bignum.c =================================================================== --- bignum.c (revision 63659) +++ bignum.c (revision 63660) @@ -6965,7 +6965,7 @@ int_pow_tmp3(VALUE x, VALUE y, VALUE m, https://github.com/ruby/ruby/blob/trunk/bignum.c#L6965 x = rb_int_modulo(x, m); } - if (nega_flg && rb_num_positive_int_p(tmp)) { + if (nega_flg && rb_int_positive_p(tmp)) { tmp = rb_int_minus(tmp, m); } return tmp; @@ -7070,14 +7070,14 @@ rb_int_powm(int const argc, VALUE * cons https://github.com/ruby/ruby/blob/trunk/bignum.c#L7070 if ( ! RB_INTEGER_TYPE_P(b)) { rb_raise(rb_eTypeError, "Integer#pow() 2nd argument not allowed unless a 1st argument is integer"); } - if (rb_num_negative_int_p(b)) { + if (rb_int_negative_p(b)) { rb_raise(rb_eRangeError, "Integer#pow() 1st argument cannot be negative when 2nd argument specified"); } if (!RB_INTEGER_TYPE_P(m)) { rb_raise(rb_eTypeError, "Integer#pow() 2nd argument not allowed unless all arguments are integers"); } - if (rb_num_negative_int_p(m)) { + if (rb_int_negative_p(m)) { m = rb_int_uminus(m); nega_flg = 1; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/