aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-19 17:55:23 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-19 17:55:23 +0100
commit87888ce4d826a117bac89fe3475a8ae859a6e42a (patch)
tree2b423fb8b3c557641ca961cac2da0c8e36ecf185 /miscutils
parentf36a0adf8b1d2720880d84dcbcb800b904aedad5 (diff)
downloadbusybox-87888ce4d826a117bac89fe3475a8ae859a6e42a.tar.gz
bc: avoid successive bc_vec_item(&func->autos, i)
function old new delta zbc_func_insert 97 100 +3 zbc_program_call 353 354 +1 zbc_program_exec 4085 4078 -7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/1 up/down: 4/-7) Total: -3 bytes text data bss dec hex filename 981403 485 7296 989184 f1800 busybox_old 981400 485 7296 989181 f17fd busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/bc.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 12e3079f1..8316933f6 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -2504,11 +2504,13 @@ static BC_STATUS zbc_num_modexp(BcNum *a, BcNum *b, BcNum *c, BcNum *restrict d)
#if ENABLE_BC
static BC_STATUS zbc_func_insert(BcFunc *f, char *name, bool var)
{
+ BcId *autoid;
BcId a;
size_t i;
- for (i = 0; i < f->autos.len; ++i) {
- if (strcmp(name, ((BcId *) bc_vec_item(&f->autos, i))->name) == 0)
+ autoid = (void*)f->autos.v;
+ for (i = 0; i < f->autos.len; i++, autoid++) {
+ if (strcmp(name, autoid->name) == 0)
RETURN_STATUS(bc_error("function parameter or auto var has the same name as another"));
}
@@ -5888,12 +5890,11 @@ static BC_STATUS zbc_program_call(char *code, size_t *idx)
if (s) RETURN_STATUS(s);
}
- for (; i < func->autos.len; ++i) {
+ a = bc_vec_item(&func->autos, i);
+ for (; i < func->autos.len; i++, a++) {
BcVec *v;
- a = bc_vec_item(&func->autos, i);
v = bc_program_search(a->name, a->idx);
-
if (a->idx) {
BcNum n2;
bc_num_init_DEF_SIZE(&n2);
@@ -5915,6 +5916,7 @@ static BC_STATUS zbc_program_return(char inst)
{
BcResult res;
BcFunc *f;
+ BcId *a;
size_t i;
BcInstPtr *ip = bc_vec_top(&G.prog.exestack);
@@ -5939,10 +5941,9 @@ static BC_STATUS zbc_program_return(char inst)
}
// We need to pop arguments as well, so this takes that into account.
- for (i = 0; i < f->autos.len; ++i) {
+ a = (void*)f->autos.v;
+ for (i = 0; i < f->autos.len; i++, a++) {
BcVec *v;
- BcId *a = bc_vec_item(&f->autos, i);
-
v = bc_program_search(a->name, a->idx);
bc_vec_pop(v);
}