summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-09 15:43:48 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-09 15:43:48 +0000
commit5ec8b6e78e08dbd645a3dceaf617bb0ad5b2c373 (patch)
treefe7027d235b74361725dd7caaa016f9351e7ae64 /bignum.c
parent55cbeefb2df3a3985d96a8538ac145c35665cfd3 (diff)
* bignum.c (bary_mul): x*1 is x.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/bignum.c b/bignum.c
index b25aebdcac..f2a61d1714 100644
--- a/bignum.c
+++ b/bignum.c
@@ -1856,6 +1856,17 @@ bary_mul(BDIGIT *zds, size_t zl, BDIGIT *xds, size_t xl, BDIGIT *yds, size_t yl,
return;
}
+ if (xl == 1 && xds[0] == 1) {
+ MEMCPY(zds, yds, BDIGIT, yl);
+ MEMZERO(zds + yl, BDIGIT, zl - yl);
+ return;
+ }
+ if (yl == 1 && yds[0] == 1) {
+ MEMCPY(zds, xds, BDIGIT, xl);
+ MEMZERO(zds + xl, BDIGIT, zl - xl);
+ return;
+ }
+
/* normal multiplication when x is small */
if (xl < KARATSUBA_MUL_DIGITS) {
normal: