ruby-changes:29446
From: akr <ko1@a...>
Date: Thu, 20 Jun 2013 22:41:18 +0900 (JST)
Subject: [ruby-changes:29446] akr:r41498 (trunk): * bignum.c (rb_uint2big): Refactored.
akr 2013-06-20 22:40:09 +0900 (Thu, 20 Jun 2013) New Revision: 41498 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41498 Log: * bignum.c (rb_uint2big): Refactored. Modified files: trunk/ChangeLog trunk/bignum.c Index: ChangeLog =================================================================== --- ChangeLog (revision 41497) +++ ChangeLog (revision 41498) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Jun 20 22:29:42 2013 Tanaka Akira <akr@f...> + + * bignum.c (rb_uint2big): Refactored. + Thu Jun 20 22:24:41 2013 Tanaka Akira <akr@f...> * bignum.c (dump_bignum): Use SIZEOF_BDIGITS. Index: bignum.c =================================================================== --- bignum.c (revision 41497) +++ bignum.c (revision 41498) @@ -336,21 +336,17 @@ rb_big_norm(VALUE x) https://github.com/ruby/ruby/blob/trunk/bignum.c#L336 VALUE rb_uint2big(VALUE n) { - long i = 0; - BDIGIT *digits; - VALUE big; + long i; + VALUE big = bignew(bdigit_roomof(SIZEOF_VALUE), 1); + BDIGIT *digits = BDIGITS(big); #if SIZEOF_BDIGITS >= SIZEOF_VALUE - big = bignew(1, 1); - digits = BDIGITS(big); digits[0] = n; #else - BDIGIT_DBL num = n; - big = bignew(bdigit_roomof(SIZEOF_VALUE), 1); - digits = BDIGITS(big); - while (i < bdigit_roomof(SIZEOF_VALUE)) { - digits[i++] = BIGLO(num); - num = BIGDN(num); + i = 0; + for (i = 0; i < bdigit_roomof(SIZEOF_VALUE); i++) { + digits[i] = BIGLO(n); + n = BIGDN(n); } #endif -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/