From 8e7686e4577ac7b07845d16fd95a39a4ce0af3c1 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 16 Dec 2018 23:18:28 +0100 Subject: [PATCH] bc: p->exits.func is never zero, do not check for that function old new delta zbc_parse_stmt_possibly_auto 1978 1967 -11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-11) Total: -11 bytes text data bss dec hex filename 981948 485 7296 989729 f1a21 busybox_old 981937 485 7296 989718 f1a16 busybox_unstripped Signed-off-by: Denys Vlasenko --- miscutils/bc.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/miscutils/bc.c b/miscutils/bc.c index af57b3d6c..ca14c1ba7 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c @@ -4232,7 +4232,6 @@ static BC_STATUS zbc_parse_for(BcParse *p) BcInstPtr ip; size_t *label; size_t cond_idx, exit_idx, body_idx, update_idx; - size_t n; dbg_lex("%s:%d p->l.t.t:%d", __func__, __LINE__, p->l.t.t); s = zbc_lex_next(&p->l); @@ -4305,16 +4304,10 @@ static BC_STATUS zbc_parse_for(BcParse *p) s = zbc_parse_stmt_fail_if_bare_NLINE(p, false, "for"); if (s) RETURN_STATUS(s); - n = *((size_t *) bc_vec_top(&p->conds)); - bc_parse_push(p, BC_INST_JUMP); - bc_parse_pushIndex(p, n); - - label = bc_vec_top(&p->conds); - //TODO: commonalize? - dbg_lex("%s:%d BC_INST_JUMP to %d", __func__, __LINE__, *label); + dbg_lex("%s:%d BC_INST_JUMP to %d", __func__, __LINE__, update_idx); bc_parse_push(p, BC_INST_JUMP); - bc_parse_pushIndex(p, *label); + bc_parse_pushIndex(p, update_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); @@ -4337,18 +4330,13 @@ static BC_STATUS zbc_parse_break_or_continue(BcParse *p, BcLexType type) if (type == BC_LEX_KEY_BREAK) { BcInstPtr *ipp; - i = p->exits.len; - for (;;) { - if (i == 0) // none of the enclosing blocks is a loop - RETURN_STATUS(bc_error_bad_token()); - ipp = bc_vec_item(&p->exits, --i); - if (ipp->func != 0) - break; - } + if (p->exits.len == 0) // none of the enclosing blocks is a loop + RETURN_STATUS(bc_error_bad_token()); + ipp = bc_vec_top(&p->exits); i = ipp->idx; - } - else + } else { i = *((size_t *) bc_vec_top(&p->conds)); + } bc_parse_push(p, BC_INST_JUMP); bc_parse_pushIndex(p, i);