From 1ea1d2e4a7911f5c43fdea2daadc2ea9201d4a4d Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 13 Apr 2016 05:12:01 +0000 Subject: numeric.c: int_round_zero_p * bignum.c (rb_big_size): add wrapper function of BIGSIZE and rename the method funtion with _m suffix. * numeric.c (int_round_zero_p): extracted from rb_int_round. optimize for Bignum, and convert VALUE returned by Numeric#size to long. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- bignum.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'bignum.c') diff --git a/bignum.c b/bignum.c index a6d669e887..e46f845c57 100644 --- a/bignum.c +++ b/bignum.c @@ -6906,6 +6906,12 @@ rb_big_abs(VALUE x) return x; } +size_t +rb_big_size(VALUE big) +{ + return BIGSIZE(big); +} + /* * call-seq: * big.size -> integer @@ -6919,9 +6925,9 @@ rb_big_abs(VALUE x) */ static VALUE -rb_big_size(VALUE big) +rb_big_size_m(VALUE big) { - return SIZET2NUM(BIGSIZE(big)); + return SIZET2NUM(rb_big_size(big)); } /* @@ -7087,7 +7093,7 @@ Init_Bignum(void) rb_define_method(rb_cBignum, "===", rb_big_eq, 1); rb_define_method(rb_cBignum, "abs", rb_big_abs, 0); rb_define_method(rb_cBignum, "magnitude", rb_big_abs, 0); - rb_define_method(rb_cBignum, "size", rb_big_size, 0); + rb_define_method(rb_cBignum, "size", rb_big_size_m, 0); rb_define_method(rb_cBignum, "bit_length", rb_big_bit_length, 0); #ifdef USE_GMP -- cgit v1.2.3