bc: store only index in p->exits, it's the only thing used there

function                                             old     new   delta
zbc_parse_stmt_possibly_auto                        1967    1964      -3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3)               Total: -3 bytes
   text	   data	    bss	    dec	    hex	filename
 981937	    485	   7296	 989718	  f1a16	busybox_old
 981934	    485	   7296	 989715	  f1a13	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2018-12-16 23:24:25 +01:00
parent 8e7686e457
commit 266aa00012
2 changed files with 22 additions and 8 deletions

View File

@ -3642,7 +3642,7 @@ static void bc_parse_create(BcParse *p, size_t func)
memset(p, 0, sizeof(BcParse)); memset(p, 0, sizeof(BcParse));
bc_lex_init(&p->l); bc_lex_init(&p->l);
bc_vec_init(&p->exits, sizeof(BcInstPtr), NULL); bc_vec_init(&p->exits, sizeof(size_t), NULL);
bc_vec_init(&p->conds, sizeof(size_t), NULL); bc_vec_init(&p->conds, sizeof(size_t), NULL);
bc_vec_init(&p->ops, sizeof(BcLexType), NULL); bc_vec_init(&p->ops, sizeof(BcLexType), NULL);
@ -4192,7 +4192,7 @@ static BC_STATUS zbc_parse_while(BcParse *p)
ip.func = 1; ip.func = 1;
ip.len = 0; ip.len = 0;
bc_vec_push(&p->exits, &ip); bc_vec_push(&p->exits, &ip.idx);
bc_vec_push(&p->func->labels, &ip.idx); bc_vec_push(&p->func->labels, &ip.idx);
s = zbc_parse_expr(p, BC_PARSE_REL, bc_parse_next_rel); s = zbc_parse_expr(p, BC_PARSE_REL, bc_parse_next_rel);
@ -4294,7 +4294,7 @@ static BC_STATUS zbc_parse_for(BcParse *p)
ip.func = 1; ip.func = 1;
ip.len = 0; ip.len = 0;
bc_vec_push(&p->exits, &ip); bc_vec_push(&p->exits, &ip.idx);
bc_vec_push(&p->func->labels, &ip.idx); bc_vec_push(&p->func->labels, &ip.idx);
// for(...)<newline>stmt is accepted as well // for(...)<newline>stmt is accepted as well
@ -4328,14 +4328,11 @@ static BC_STATUS zbc_parse_break_or_continue(BcParse *p, BcLexType type)
size_t i; size_t i;
if (type == BC_LEX_KEY_BREAK) { if (type == BC_LEX_KEY_BREAK) {
BcInstPtr *ipp;
if (p->exits.len == 0) // none of the enclosing blocks is a loop if (p->exits.len == 0) // none of the enclosing blocks is a loop
RETURN_STATUS(bc_error_bad_token()); RETURN_STATUS(bc_error_bad_token());
ipp = bc_vec_top(&p->exits); i = *(size_t*)bc_vec_top(&p->exits);
i = ipp->idx;
} else { } else {
i = *((size_t *) bc_vec_top(&p->conds)); i = *(size_t*)bc_vec_top(&p->conds);
} }
bc_parse_push(p, BC_INST_JUMP); bc_parse_push(p, BC_INST_JUMP);

View File

@ -134,6 +134,23 @@ while(i--) {
99 99
" "
testing "bc continue in for" \
"bc" \
"\
1
77
2
99
" \
"" "\
for(i=1; i<3; i++) {
i
if(i==2) continue
77
}
99
"
tar xJf bc_large.tar.xz tar xJf bc_large.tar.xz
for f in bc*.bc; do for f in bc*.bc; do