* bignum.c (rb_uint2big): Refactored.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-06-20 13:40:09 +00:00
parent ca10999c39
commit 94e5fdf336
2 changed files with 11 additions and 11 deletions

View File

@ -1,3 +1,7 @@
Thu Jun 20 22:29:42 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (rb_uint2big): Refactored.
Thu Jun 20 22:24:41 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (dump_bignum): Use SIZEOF_BDIGITS.

View File

@ -336,21 +336,17 @@ rb_big_norm(VALUE x)
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