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>
This commit is contained in:
Denys Vlasenko 2018-12-05 18:56:14 +01:00
parent 0d7e46b1de
commit b692c2faf1

View File

@ -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;