ruby-changes:30257
From: akr <ko1@a...>
Date: Thu, 1 Aug 2013 23:35:11 +0900 (JST)
Subject: [ruby-changes:30257] akr:r42309 (trunk): * bignum.c (rb_cstr_to_inum): Use power_cache_get_power.
akr 2013-08-01 23:34:59 +0900 (Thu, 01 Aug 2013) New Revision: 42309 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42309 Log: * bignum.c (rb_cstr_to_inum): Use power_cache_get_power. Modified files: trunk/ChangeLog trunk/bignum.c Index: ChangeLog =================================================================== --- ChangeLog (revision 42308) +++ ChangeLog (revision 42309) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Aug 1 23:33:01 2013 Tanaka Akira <akr@f...> + + * bignum.c (rb_cstr_to_inum): Use power_cache_get_power. + Thu Aug 1 21:02:48 2013 Tanaka Akira <akr@f...> * bignum.c (rb_big2str1): Raise an error for too big number. Index: bignum.c =================================================================== --- bignum.c (revision 42308) +++ bignum.c (revision 42309) @@ -141,6 +141,7 @@ static inline VALUE bigtrunc(VALUE x); https://github.com/ruby/ruby/blob/trunk/bignum.c#L141 static VALUE bigsq(VALUE x); static void bigdivmod(VALUE x, VALUE y, volatile VALUE *divp, volatile VALUE *modp); +static VALUE power_cache_get_power(int base, int power_level, size_t *numdigits_ret); static int nlz16(uint16_t x) @@ -3833,13 +3834,12 @@ rb_cstr_to_inum(const char *str, int bas https://github.com/ruby/ruby/blob/trunk/bignum.c#L3834 BDIGIT_DBL dd; BDIGIT_DBL current_base; int m; + int power_level = 0; uds = ALLOCV_N(BDIGIT, tmpuv, 2*num_bdigits); vds = uds + num_bdigits; - powerv = bignew(2, 1); - BDIGITS(powerv)[0] = BIGLO(power); - BDIGITS(powerv)[1] = (BDIGIT)BIGDN(power); + powerv = power_cache_get_power(base, power_level, NULL); i = 0; dd = 0; @@ -3879,7 +3879,8 @@ rb_cstr_to_inum(const char *str, int bas https://github.com/ruby/ruby/blob/trunk/bignum.c#L3879 MEMCPY(vds+i, uds+i, BDIGIT, num_bdigits-i); } } - powerv = bigtrunc(bigsq(powerv)); + power_level++; + powerv = power_cache_get_power(base, power_level, NULL); tds = vds; vds = uds; uds = tds; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/