ruby-changes:30045
From: akr <ko1@a...>
Date: Mon, 22 Jul 2013 00:17:20 +0900 (JST)
Subject: [ruby-changes:30045] akr:r42097 (trunk): * bignum.c (bary_sq_fast): Refine expressions.
akr 2013-07-22 00:17:09 +0900 (Mon, 22 Jul 2013) New Revision: 42097 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42097 Log: * bignum.c (bary_sq_fast): Refine expressions. Modified files: trunk/ChangeLog trunk/bignum.c Index: ChangeLog =================================================================== --- ChangeLog (revision 42096) +++ ChangeLog (revision 42097) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Jul 22 00:15:20 2013 Tanaka Akira <akr@f...> + + * bignum.c (bary_sq_fast): Refine expressions. + Sun Jul 21 21:08:59 2013 Tanaka Akira <akr@f...> * bignum.c (bary_mul): Use simple multiplication if yl is small. Index: bignum.c =================================================================== --- bignum.c (revision 42096) +++ bignum.c (revision 42097) @@ -1601,6 +1601,8 @@ bary_sq_fast(BDIGIT *zds, size_t zn, BDI https://github.com/ruby/ruby/blob/trunk/bignum.c#L1601 { size_t i, j; BDIGIT_DBL c, v, w; + BDIGIT vl; + int vh; assert(xn * 2 <= zn); @@ -1617,12 +1619,14 @@ bary_sq_fast(BDIGIT *zds, size_t zn, BDI https://github.com/ruby/ruby/blob/trunk/bignum.c#L1619 zds[i + i] = BIGLO(c); c = BIGDN(c); v *= 2; + vl = BIGLO(v); + vh = (int)BIGDN(v); for (j = i + 1; j < xn; j++) { w = (BDIGIT_DBL)xds[j]; - c += (BDIGIT_DBL)zds[i + j] + BIGLO(v) * w; + c += (BDIGIT_DBL)zds[i + j] + vl * w; zds[i + j] = BIGLO(c); c = BIGDN(c); - if (BIGDN(v)) + if (vh) c += w; } if (c) { @@ -1642,8 +1646,7 @@ bary_sq_fast(BDIGIT *zds, size_t zn, BDI https://github.com/ruby/ruby/blob/trunk/bignum.c#L1646 zds[i + i] = BIGLO(c); c = BIGDN(c); if (c) { - c += (BDIGIT_DBL)zds[i + xn]; - zds[i + xn] = BIGLO(c); + zds[i + xn] += BIGLO(c); } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/