* bignum.c (rb_ull2big): Refactored.

(rb_uint2big): Useless code removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-06-20 21:45:11 +00:00
parent d1c518d416
commit de8ca8a138
2 changed files with 16 additions and 11 deletions

View File

@ -1,3 +1,8 @@
Fri Jun 21 06:43:59 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (rb_ull2big): Refactored.
(rb_uint2big): Useless code removed.
Fri Jun 21 05:37:39 2013 Koichi Sasada <ko1@atdot.net> Fri Jun 21 05:37:39 2013 Koichi Sasada <ko1@atdot.net>
* gc.c (gc_prof_sweep_timer_stop): accumulate sweep time only when * gc.c (gc_prof_sweep_timer_stop): accumulate sweep time only when

View File

@ -345,7 +345,6 @@ rb_uint2big(VALUE n)
#if SIZEOF_BDIGITS >= SIZEOF_VALUE #if SIZEOF_BDIGITS >= SIZEOF_VALUE
digits[0] = n; digits[0] = n;
#else #else
i = 0;
for (i = 0; i < bdigit_roomof(SIZEOF_VALUE); i++) { for (i = 0; i < bdigit_roomof(SIZEOF_VALUE); i++) {
digits[i] = BIGLO(n); digits[i] = BIGLO(n);
n = BIGDN(n); n = BIGDN(n);
@ -1830,19 +1829,20 @@ rb_str_to_inum(VALUE str, int base, int badcheck)
static VALUE static VALUE
rb_ull2big(unsigned LONG_LONG n) rb_ull2big(unsigned LONG_LONG n)
{ {
BDIGIT_DBL num = n; long i;
long i = 0; VALUE big = bignew(DIGSPERLL, bdigit_roomof(SIZEOF_LONG_LONG));
BDIGIT *digits; BDIGIT *digits = BDIGITS(big);
VALUE big;
big = bignew(DIGSPERLL, 1); #if SIZEOF_BDIGITS >= SIZEOF_LONG_LONG
digits = BDIGITS(big); digits[0] = n;
while (i < DIGSPERLL) { #else
digits[i++] = BIGLO(num); for (i = 0; i < bdigit_roomof(SIZEOF_LONG_LONG); i++) {
num = BIGDN(num); digits[i] = BIGLO(n);
n = BIGDN(n);
} }
#endif
i = DIGSPERLL; i = bdigit_roomof(SIZEOF_LONG_LONG);
while (i-- && !digits[i]) ; while (i-- && !digits[i]) ;
RBIGNUM_SET_LEN(big, i+1); RBIGNUM_SET_LEN(big, i+1);
return big; return big;