aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-16 23:35:04 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-16 23:35:04 +0100
commit5ebd2a612843821989f979b4277931d53b90671d (patch)
tree307dca2c04b9a69646db62b60f317f4faefdcce6 /miscutils
parent266aa000126dcbb9e1c93306165f433a167bb50a (diff)
downloadbusybox-5ebd2a612843821989f979b4277931d53b90671d.tar.gz
bc: remove use of "BcInstPtr ip" object from loop parsing
function old new delta zbc_parse_stmt_possibly_auto 1964 1909 -55 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-55) Total: -55 bytes text data bss dec hex filename 981934 485 7296 989715 f1a13 busybox_old 981879 485 7296 989660 f19dc busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/bc.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 979d5113d..56a2bca71 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -4173,9 +4173,9 @@ static BC_STATUS zbc_parse_if(BcParse *p)
static BC_STATUS zbc_parse_while(BcParse *p)
{
BcStatus s;
- BcInstPtr ip;
size_t *label;
size_t cond_idx;
+ size_t ip_idx;
s = zbc_lex_next(&p->l);
if (s) RETURN_STATUS(s);
@@ -4184,16 +4184,13 @@ static BC_STATUS zbc_parse_while(BcParse *p)
if (s) RETURN_STATUS(s);
cond_idx = p->func->labels.len;
+ ip_idx = cond_idx + 1;
bc_vec_push(&p->func->labels, &p->func->code.len);
bc_vec_push(&p->conds, &cond_idx);
- ip.idx = p->func->labels.len;
- ip.func = 1;
- ip.len = 0;
-
- bc_vec_push(&p->exits, &ip.idx);
- bc_vec_push(&p->func->labels, &ip.idx);
+ bc_vec_push(&p->exits, &ip_idx);
+ bc_vec_push(&p->func->labels, &ip_idx);
s = zbc_parse_expr(p, BC_PARSE_REL, bc_parse_next_rel);
if (s) RETURN_STATUS(s);
@@ -4204,7 +4201,7 @@ static BC_STATUS zbc_parse_while(BcParse *p)
if (s) RETURN_STATUS(s);
bc_parse_push(p, BC_INST_JUMP_ZERO);
- bc_parse_pushIndex(p, ip.idx);
+ bc_parse_pushIndex(p, ip_idx);
s = zbc_parse_stmt_fail_if_bare_NLINE(p, false, "while");
if (s) RETURN_STATUS(s);
@@ -4213,7 +4210,7 @@ static BC_STATUS zbc_parse_while(BcParse *p)
bc_parse_push(p, BC_INST_JUMP);
bc_parse_pushIndex(p, cond_idx);
- label = bc_vec_item(&p->func->labels, ip.idx);
+ label = bc_vec_item(&p->func->labels, ip_idx);
dbg_lex("%s:%d rewriting label: %d -> %d", __func__, __LINE__, *label, p->func->code.len);
*label = p->func->code.len;
@@ -4229,7 +4226,6 @@ static BC_STATUS zbc_parse_while(BcParse *p)
static BC_STATUS zbc_parse_for(BcParse *p)
{
BcStatus s;
- BcInstPtr ip;
size_t *label;
size_t cond_idx, exit_idx, body_idx, update_idx;
@@ -4273,8 +4269,6 @@ static BC_STATUS zbc_parse_for(BcParse *p)
bc_parse_push(p, BC_INST_JUMP);
bc_parse_pushIndex(p, body_idx);
- ip.idx = p->func->labels.len;
-
bc_vec_push(&p->conds, &update_idx);
bc_vec_push(&p->func->labels, &p->func->code.len);
@@ -4290,12 +4284,8 @@ static BC_STATUS zbc_parse_for(BcParse *p)
bc_parse_pushIndex(p, cond_idx);
bc_vec_push(&p->func->labels, &p->func->code.len);
- ip.idx = exit_idx;
- ip.func = 1;
- ip.len = 0;
-
- bc_vec_push(&p->exits, &ip.idx);
- bc_vec_push(&p->func->labels, &ip.idx);
+ bc_vec_push(&p->exits, &exit_idx);
+ bc_vec_push(&p->func->labels, &exit_idx);
// for(...)<newline>stmt is accepted as well
s = zbc_lex_next_and_skip_NLINE(&p->l);
@@ -4309,7 +4299,7 @@ static BC_STATUS zbc_parse_for(BcParse *p)
bc_parse_push(p, BC_INST_JUMP);
bc_parse_pushIndex(p, update_idx);
- label = bc_vec_item(&p->func->labels, ip.idx);
+ label = bc_vec_item(&p->func->labels, exit_idx);
dbg_lex("%s:%d rewriting label: %d -> %d", __func__, __LINE__, *label, p->func->code.len);
*label = p->func->code.len;