ruby-changes:30292
From: akr <ko1@a...>
Date: Sat, 3 Aug 2013 02:24:31 +0900 (JST)
Subject: [ruby-changes:30292] akr:r42344 (trunk): * bignum.c (big2str_orig): Refactored.
akr 2013-08-03 02:24:19 +0900 (Sat, 03 Aug 2013) New Revision: 42344 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42344 Log: * bignum.c (big2str_orig): Refactored. Modified files: trunk/ChangeLog trunk/bignum.c Index: ChangeLog =================================================================== --- ChangeLog (revision 42343) +++ ChangeLog (revision 42344) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 -Sat Aug 3 01:40:33 2013 Tanaka Akira <akr@f...> +Sat Aug 3 02:22:05 2013 Tanaka Akira <akr@f...> - * bignum.c (big2str_orig): Rename a local variable. + * bignum.c (big2str_orig): Refactored. Sat Aug 3 01:20:19 2013 Tanaka Akira <akr@f...> Index: bignum.c =================================================================== --- bignum.c (revision 42343) +++ bignum.c (revision 42344) @@ -4251,7 +4251,6 @@ big2str_orig(struct big2str_struct *b2s, https://github.com/ruby/ruby/blob/trunk/bignum.c#L4251 { long i = RBIGNUM_LEN(x); size_t j; - int k; BDIGIT* ds = BDIGITS(x); BDIGIT_DBL num; char buf[SIZEOF_BDIGIT_DBL*CHAR_BIT], *p; @@ -4271,27 +4270,23 @@ big2str_orig(struct big2str_struct *b2s, https://github.com/ruby/ruby/blob/trunk/bignum.c#L4270 return; p = buf; j = sizeof(buf); - } - else { - power_cache_get_power(b2s->base, 0, &len); - p = b2s->ptr; - j = len; - } - - k = b2s->hbase2_numdigits; - while (k--) { - p[--j] = ruby_digitmap[num % b2s->base]; - num /= b2s->base; - if (j <= 0) break; - if (beginning && num == 0) break; - } - if (beginning) { - while (j < sizeof(buf) && buf[j] == '0') - j++; + do { + p[--j] = ruby_digitmap[num % b2s->base]; + num /= b2s->base; + } while (num); len = sizeof(buf) - j; big2str_alloc(b2s, len + taillen); MEMCPY(b2s->ptr, buf + j, char, len); } + else { + p = b2s->ptr; + j = b2s->hbase2_numdigits; + do { + p[--j] = ruby_digitmap[num % b2s->base]; + num /= b2s->base; + } while (j); + len = b2s->hbase2_numdigits; + } b2s->ptr += len; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/