diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-02 03:28:33 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-08-02 03:28:33 +0000 |
commit | 9e8f82e087ac7bc34098f94c2db5ea658dd6be80 (patch) | |
tree | 70130c48c209bbd23a1cbbeefece23008a8672ca /bignum.c | |
parent | 29c5a3b89c5127edd7754d2105ef64c88ac29566 (diff) |
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -2559,12 +2559,20 @@ bary_mul_toom3_start(BDIGIT *zds, size_t zl, const BDIGIT *xds, size_t xl, const 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); |