diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-19 17:55:23 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-19 17:55:23 +0100 |
commit | 87888ce4d826a117bac89fe3475a8ae859a6e42a (patch) | |
tree | 2b423fb8b3c557641ca961cac2da0c8e36ecf185 /miscutils/bc.c | |
parent | f36a0adf8b1d2720880d84dcbcb800b904aedad5 (diff) | |
download | busybox-w32-87888ce4d826a117bac89fe3475a8ae859a6e42a.tar.gz busybox-w32-87888ce4d826a117bac89fe3475a8ae859a6e42a.tar.bz2 busybox-w32-87888ce4d826a117bac89fe3475a8ae859a6e42a.zip |
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 '')
-rw-r--r-- | miscutils/bc.c | 17 |
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) | |||
2504 | #if ENABLE_BC | 2504 | #if ENABLE_BC |
2505 | static BC_STATUS zbc_func_insert(BcFunc *f, char *name, bool var) | 2505 | static BC_STATUS zbc_func_insert(BcFunc *f, char *name, bool var) |
2506 | { | 2506 | { |
2507 | BcId *autoid; | ||
2507 | BcId a; | 2508 | BcId a; |
2508 | size_t i; | 2509 | size_t i; |
2509 | 2510 | ||
2510 | for (i = 0; i < f->autos.len; ++i) { | 2511 | autoid = (void*)f->autos.v; |
2511 | if (strcmp(name, ((BcId *) bc_vec_item(&f->autos, i))->name) == 0) | 2512 | for (i = 0; i < f->autos.len; i++, autoid++) { |
2513 | if (strcmp(name, autoid->name) == 0) | ||
2512 | RETURN_STATUS(bc_error("function parameter or auto var has the same name as another")); | 2514 | RETURN_STATUS(bc_error("function parameter or auto var has the same name as another")); |
2513 | } | 2515 | } |
2514 | 2516 | ||
@@ -5888,12 +5890,11 @@ static BC_STATUS zbc_program_call(char *code, size_t *idx) | |||
5888 | if (s) RETURN_STATUS(s); | 5890 | if (s) RETURN_STATUS(s); |
5889 | } | 5891 | } |
5890 | 5892 | ||
5891 | for (; i < func->autos.len; ++i) { | 5893 | a = bc_vec_item(&func->autos, i); |
5894 | for (; i < func->autos.len; i++, a++) { | ||
5892 | BcVec *v; | 5895 | BcVec *v; |
5893 | 5896 | ||
5894 | a = bc_vec_item(&func->autos, i); | ||
5895 | v = bc_program_search(a->name, a->idx); | 5897 | v = bc_program_search(a->name, a->idx); |
5896 | |||
5897 | if (a->idx) { | 5898 | if (a->idx) { |
5898 | BcNum n2; | 5899 | BcNum n2; |
5899 | bc_num_init_DEF_SIZE(&n2); | 5900 | bc_num_init_DEF_SIZE(&n2); |
@@ -5915,6 +5916,7 @@ static BC_STATUS zbc_program_return(char inst) | |||
5915 | { | 5916 | { |
5916 | BcResult res; | 5917 | BcResult res; |
5917 | BcFunc *f; | 5918 | BcFunc *f; |
5919 | BcId *a; | ||
5918 | size_t i; | 5920 | size_t i; |
5919 | BcInstPtr *ip = bc_vec_top(&G.prog.exestack); | 5921 | BcInstPtr *ip = bc_vec_top(&G.prog.exestack); |
5920 | 5922 | ||
@@ -5939,10 +5941,9 @@ static BC_STATUS zbc_program_return(char inst) | |||
5939 | } | 5941 | } |
5940 | 5942 | ||
5941 | // We need to pop arguments as well, so this takes that into account. | 5943 | // We need to pop arguments as well, so this takes that into account. |
5942 | for (i = 0; i < f->autos.len; ++i) { | 5944 | a = (void*)f->autos.v; |
5945 | for (i = 0; i < f->autos.len; i++, a++) { | ||
5943 | BcVec *v; | 5946 | BcVec *v; |
5944 | BcId *a = bc_vec_item(&f->autos, i); | ||
5945 | |||
5946 | v = bc_program_search(a->name, a->idx); | 5947 | v = bc_program_search(a->name, a->idx); |
5947 | bc_vec_pop(v); | 5948 | bc_vec_pop(v); |
5948 | } | 5949 | } |