ruby-changes:29453
From: akr <ko1@a...>
Date: Fri, 21 Jun 2013 06:45:24 +0900 (JST)
Subject: [ruby-changes:29453] akr:r41505 (trunk): * bignum.c (rb_ull2big): Refactored.
akr 2013-06-21 06:45:11 +0900 (Fri, 21 Jun 2013) New Revision: 41505 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41505 Log: * bignum.c (rb_ull2big): Refactored. (rb_uint2big): Useless code removed. Modified files: trunk/ChangeLog trunk/bignum.c Index: ChangeLog =================================================================== --- ChangeLog (revision 41504) +++ ChangeLog (revision 41505) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Jun 21 06:43:59 2013 Tanaka Akira <akr@f...> + + * bignum.c (rb_ull2big): Refactored. + (rb_uint2big): Useless code removed. + Fri Jun 21 05:37:39 2013 Koichi Sasada <ko1@a...> * gc.c (gc_prof_sweep_timer_stop): accumulate sweep time only when Index: bignum.c =================================================================== --- bignum.c (revision 41504) +++ bignum.c (revision 41505) @@ -345,7 +345,6 @@ rb_uint2big(VALUE n) https://github.com/ruby/ruby/blob/trunk/bignum.c#L345 #if SIZEOF_BDIGITS >= SIZEOF_VALUE digits[0] = n; #else - i = 0; for (i = 0; i < bdigit_roomof(SIZEOF_VALUE); i++) { digits[i] = BIGLO(n); n = BIGDN(n); @@ -1830,19 +1829,20 @@ rb_str_to_inum(VALUE str, int base, int https://github.com/ruby/ruby/blob/trunk/bignum.c#L1829 static VALUE rb_ull2big(unsigned LONG_LONG n) { - BDIGIT_DBL num = n; - long i = 0; - BDIGIT *digits; - VALUE big; + long i; + VALUE big = bignew(DIGSPERLL, bdigit_roomof(SIZEOF_LONG_LONG)); + BDIGIT *digits = BDIGITS(big); - big = bignew(DIGSPERLL, 1); - digits = BDIGITS(big); - while (i < DIGSPERLL) { - digits[i++] = BIGLO(num); - num = BIGDN(num); +#if SIZEOF_BDIGITS >= SIZEOF_LONG_LONG + digits[0] = n; +#else + for (i = 0; i < bdigit_roomof(SIZEOF_LONG_LONG); i++) { + digits[i] = BIGLO(n); + n = BIGDN(n); } +#endif - i = DIGSPERLL; + i = bdigit_roomof(SIZEOF_LONG_LONG); while (i-- && !digits[i]) ; RBIGNUM_SET_LEN(big, i+1); return big; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/