summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-02 03:28:33 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-02 03:28:33 +0000
commit9e8f82e087ac7bc34098f94c2db5ea658dd6be80 (patch)
tree70130c48c209bbd23a1cbbeefece23008a8672ca
parent29c5a3b89c5127edd7754d2105ef64c88ac29566 (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
-rw-r--r--ChangeLog5
-rw-r--r--bignum.c20
2 files changed, 19 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index cec7b5d..d11f4c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Aug 2 12:25:15 2013 Tanaka Akira <akr@fsij.org>
+
+ * 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@ruby-lang.org>
* parse.y (negate_lit): add T_RATIONAL and T_COMPLEX to the switch
diff --git a/bignum.c b/bignum.c
index 0621180..fffb65f 100644
--- a/bignum.c
+++ b/bignum.c
@@ -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);