ruby-changes:30272
From: akr <ko1@a...>
Date: Fri, 2 Aug 2013 12:28:46 +0900 (JST)
Subject: [ruby-changes:30272] akr:r42324 (trunk): * bignum.c (bary_mul): Swap x and y for bary_mul1 if x is longer than y.
akr 2013-08-02 12:28:33 +0900 (Fri, 02 Aug 2013) New Revision: 42324 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42324 Log: * bignum.c (bary_mul): Swap x and y for bary_mul1 if x is longer than y. [ruby-dev:47565] [Bug #8719] Reported by Narihiro Nakamura. Modified files: trunk/ChangeLog trunk/bignum.c Index: ChangeLog =================================================================== --- ChangeLog (revision 42323) +++ ChangeLog (revision 42324) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Aug 2 12:25:15 2013 Tanaka Akira <akr@f...> + + * bignum.c (bary_mul): Swap x and y for bary_mul1 if x is longer than y. + [ruby-dev:47565] [Bug #8719] Reported by Narihiro Nakamura. + Fri Aug 2 10:39:00 2013 Charlie Somerville <charliesome@r...> * parse.y (negate_lit): add T_RATIONAL and T_COMPLEX to the switch Index: bignum.c =================================================================== --- bignum.c (revision 42323) +++ bignum.c (revision 42324) @@ -2559,12 +2559,20 @@ bary_mul_toom3_start(BDIGIT *zds, size_t https://github.com/ruby/ruby/blob/trunk/bignum.c#L2559 static void bary_mul(BDIGIT *zds, size_t zl, const BDIGIT *xds, size_t xl, const BDIGIT *yds, size_t yl) { - if (xl < KARATSUBA_MUL_DIGITS || yl < KARATSUBA_MUL_DIGITS) { - if (xds == yds && xl == yl) - bary_sq_fast(zds, zl, xds, xl); - else - bary_mul1(zds, zl, xds, xl, yds, yl); - return; + if (xl <= yl) { + if (yl < KARATSUBA_MUL_DIGITS) { + if (xds == yds && xl == yl) + bary_sq_fast(zds, zl, xds, xl); + else + bary_mul1(zds, zl, xds, xl, yds, yl); + return; + } + } + else { + if (xl < KARATSUBA_MUL_DIGITS) { + bary_mul1(zds, zl, yds, yl, xds, xl); + return; + } } bary_mul_toom3_start(zds, zl, xds, xl, yds, yl, NULL, 0); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/