aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-09 12:04:44 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-09 12:04:44 +0100
commit3129f705fc630cf597abeaa97000f896d2813d52 (patch)
treec4e8651428641f43e3154992d1eb8f6cd47d0e9e
parente20e00de341518f2a9d49bde77b9e4876b472a4e (diff)
downloadbusybox-w32-3129f705fc630cf597abeaa97000f896d2813d52.tar.gz
busybox-w32-3129f705fc630cf597abeaa97000f896d2813d52.tar.bz2
busybox-w32-3129f705fc630cf597abeaa97000f896d2813d52.zip
bc: no need to "set to zero" BcNum after bc_num_init(), it already is
function old new delta bc_num_init 48 49 +1 bc_program_num 1115 1108 -7 bc_program_exec 4098 4081 -17 bc_vm_init 786 768 -18 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/3 up/down: 1/-42) Total: -41 bytes text data bss dec hex filename 985872 477 7296 993645 f296d busybox_old 985831 477 7296 993604 f2944 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 2e3c4139e..71b419d8f 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -1399,12 +1399,16 @@ static void bc_num_ten(BcNum *n)
1399 n->num[1] = 1; 1399 n->num[1] = 1;
1400} 1400}
1401 1401
1402// Note: this also sets BcNum to zero
1402static void bc_num_init(BcNum *n, size_t req) 1403static void bc_num_init(BcNum *n, size_t req)
1403{ 1404{
1404 req = req >= BC_NUM_DEF_SIZE ? req : BC_NUM_DEF_SIZE; 1405 req = req >= BC_NUM_DEF_SIZE ? req : BC_NUM_DEF_SIZE;
1405 memset(n, 0, sizeof(BcNum)); 1406 //memset(n, 0, sizeof(BcNum)); - cleared by assignments below
1406 n->num = xmalloc(req); 1407 n->num = xmalloc(req);
1407 n->cap = req; 1408 n->cap = req;
1409 n->rdx = 0;
1410 n->len = 0;
1411 n->neg = false;
1408} 1412}
1409 1413
1410static void bc_num_init_DEF_SIZE(BcNum *n) 1414static void bc_num_init_DEF_SIZE(BcNum *n)
@@ -2288,7 +2292,7 @@ static void bc_num_parseBase(BcNum *n, const char *val, BcNum *base)
2288 } 2292 }
2289 2293
2290 bc_num_init(&result, base->len); 2294 bc_num_init(&result, base->len);
2291 bc_num_zero(&result); 2295 //bc_num_zero(&result); - already is
2292 bc_num_one(&mult); 2296 bc_num_one(&mult);
2293 2297
2294 for (i += 1, digits = 0; i < len; ++i, ++digits) { 2298 for (i += 1, digits = 0; i < len; ++i, ++digits) {
@@ -6209,7 +6213,7 @@ static BcStatus bc_program_return(char inst)
6209 } 6213 }
6210 else { 6214 else {
6211 bc_num_init_DEF_SIZE(&res.d.n); 6215 bc_num_init_DEF_SIZE(&res.d.n);
6212 bc_num_zero(&res.d.n); 6216 //bc_num_zero(&res.d.n); - already is
6213 } 6217 }
6214 6218
6215 // We need to pop arguments as well, so this takes that into account. 6219 // We need to pop arguments as well, so this takes that into account.
@@ -6768,8 +6772,7 @@ static BcStatus bc_program_exec(void)
6768 bc_num_init_DEF_SIZE(&r.d.n); 6772 bc_num_init_DEF_SIZE(&r.d.n);
6769 if (!bc_num_cmp(num, &G.prog.zero)) 6773 if (!bc_num_cmp(num, &G.prog.zero))
6770 bc_num_one(&r.d.n); 6774 bc_num_one(&r.d.n);
6771 else 6775 //else bc_num_zero(&r.d.n); - already is
6772 bc_num_zero(&r.d.n);
6773 bc_program_retire(&r, BC_RESULT_TEMP); 6776 bc_program_retire(&r, BC_RESULT_TEMP);
6774 break; 6777 break;
6775 case BC_INST_NEG: 6778 case BC_INST_NEG:
@@ -7379,10 +7382,10 @@ static void bc_program_init(void)
7379#endif 7382#endif
7380 7383
7381 bc_num_init_DEF_SIZE(&G.prog.last); 7384 bc_num_init_DEF_SIZE(&G.prog.last);
7382 bc_num_zero(&G.prog.last); 7385 //bc_num_zero(&G.prog.last); - already is
7383 7386
7384 bc_num_init_DEF_SIZE(&G.prog.zero); 7387 bc_num_init_DEF_SIZE(&G.prog.zero);
7385 bc_num_zero(&G.prog.zero); 7388 //bc_num_zero(&G.prog.zero); - already is
7386 7389
7387 bc_num_init_DEF_SIZE(&G.prog.one); 7390 bc_num_init_DEF_SIZE(&G.prog.one);
7388 bc_num_one(&G.prog.one); 7391 bc_num_one(&G.prog.one);