summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2018-12-05 18:56:14 +0100
committerDenys Vlasenko2018-12-05 18:56:14 +0100
commitb692c2faf1e713fe4ec04d34bd6ad77e02dbb5d6 (patch)
tree533e5df4cb205d0959991fbee21f25a6d803fbfe
parent0d7e46b1de8f11ccff9a5efa5d6d6ea6f5bacabf (diff)
downloadbusybox-b692c2faf1e713fe4ec04d34bd6ad77e02dbb5d6.zip
busybox-b692c2faf1e713fe4ec04d34bd6ad77e02dbb5d6.tar.gz
bc: bc_num_k(): move carry,i,j,len to inner scope
This might help compiler function old new delta bc_num_k 957 971 +14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index a78446d..ea200eb 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -1639,16 +1639,16 @@ static BcStatus bc_num_k(BcNum *restrict a, BcNum *restrict b,
BcNum *restrict c)
{
BcStatus s;
- int carry;
- size_t i, j, len, max = BC_MAX(a->len, b->len), max2 = (max + 1) / 2;
+ size_t max = BC_MAX(a->len, b->len), max2 = (max + 1) / 2;
BcNum l1, h1, l2, h2, m2, m1, z0, z1, z2, temp;
- bool aone = BC_NUM_ONE(a);
+ bool aone;
if (a->len == 0 || b->len == 0) {
bc_num_zero(c);
return BC_STATUS_SUCCESS;
}
- else if (aone || BC_NUM_ONE(b)) {
+ aone = BC_NUM_ONE(a);
+ if (aone || BC_NUM_ONE(b)) {
bc_num_copy(c, aone ? b : a);
return BC_STATUS_SUCCESS;
}
@@ -1656,13 +1656,17 @@ static BcStatus bc_num_k(BcNum *restrict a, BcNum *restrict b,
if (a->len + b->len < BC_NUM_KARATSUBA_LEN ||
a->len < BC_NUM_KARATSUBA_LEN || b->len < BC_NUM_KARATSUBA_LEN)
{
+ size_t i, j, len;
+ int carry;
+
bc_num_expand(c, a->len + b->len + 1);
memset(c->num, 0, sizeof(BcDig) * c->cap);
- c->len = carry = len = 0;
+ c->len = len = 0;
for (i = 0; i < b->len; ++i) {
+ carry = 0;
for (j = 0; j < a->len; ++j) {
int in = (int) c->num[i + j];
in += ((int) a->num[j]) * ((int) b->num[i]) + carry;
@@ -1672,7 +1676,6 @@ static BcStatus bc_num_k(BcNum *restrict a, BcNum *restrict b,
c->num[i + j] += (BcDig) carry;
len = BC_MAX(len, i + j + !!carry);
- carry = 0;
}
c->len = len;