summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-07 15:21:26 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-07 15:21:26 +0000
commit1210743cad827155f4e2d4da9adbb8c1569a93a6 (patch)
treec06c134abc058bb7add5dd953b5d89d9654d8b06 /bignum.c
parentc51615963af25a50e52cf933298d6405eb611d7a (diff)
* bignum.c (bary_mul_karatsuba): Unreachable code removed. Remove
several branches. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/bignum.c b/bignum.c
index 31d35b2d78..4c1c5f74a1 100644
--- a/bignum.c
+++ b/bignum.c
@@ -1593,8 +1593,8 @@ bary_mul_karatsuba(BDIGIT *zds, size_t zl, BDIGIT *xds, size_t xl, BDIGIT *yds,
size_t n;
int sub_p, borrow, carry1, carry2, carry3;
- int odd_x = 0;
int odd_y = 0;
+ int odd_xy = 0;
BDIGIT *xds0, *xds1, *yds0, *yds1, *zds0, *zds1, *zds2, *zds3;
@@ -1606,7 +1606,7 @@ bary_mul_karatsuba(BDIGIT *zds, size_t zl, BDIGIT *xds, size_t xl, BDIGIT *yds,
odd_y = 1;
yl--;
if (yl < xl) {
- odd_x = 1;
+ odd_xy = 1;
xl--;
}
}
@@ -1706,15 +1706,10 @@ bary_mul_karatsuba(BDIGIT *zds, size_t zl, BDIGIT *xds, size_t xl, BDIGIT *yds,
if (carry2)
bary_add_one(zds2, zl-2*n);
- if (borrow && carry1)
- borrow = carry1 = 0;
- if (borrow && carry3)
- borrow = carry3 = 0;
-
- if (borrow)
+ if (carry1 + carry3 - borrow < 0)
bary_sub_one(zds3, zl-3*n);
- else if (carry1 || carry3) {
- BDIGIT c = carry1 + carry3;
+ else if (carry1 + carry3 - borrow > 0) {
+ BDIGIT c = carry1 + carry3 - borrow;
bary_add(zds3, zl-3*n, zds3, zl-3*n, &c, 1);
}
@@ -1729,13 +1724,10 @@ bary_mul_karatsuba(BDIGIT *zds, size_t zl, BDIGIT *xds, size_t xl, BDIGIT *yds,
}
*/
- if (odd_x && odd_y) {
+ if (odd_xy) {
bary_muladd_1xN(zds+yl, zl-yl, yds[yl], xds, xl);
bary_muladd_1xN(zds+xl, zl-xl, xds[xl], yds, yl+1);
}
- else if (odd_x) {
- bary_muladd_1xN(zds+xl, zl-xl, xds[xl], yds, yl);
- }
else if (odd_y) {
bary_muladd_1xN(zds+yl, zl-yl, yds[yl], xds, xl);
}