aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Denys Vlasenko <vda.linux@googlemail.com>2019-01-09 11:17:19 +0100
committerGravatar Denys Vlasenko <vda.linux@googlemail.com>2019-02-14 14:40:57 +0100
commitb5709543631aaa9a198dbb726b1d302a1696410e (patch)
treeeffcd1e7f61be9193c3b40229aaa6044daffdd1f
parentc28dc0b58bac65e3904828a82ea29712ba967e84 (diff)
downloadbusybox-b5709543631aaa9a198dbb726b1d302a1696410e.tar.gz
busybox-b5709543631aaa9a198dbb726b1d302a1696410e.tar.bz2
bc: code shrink
function old new delta xc_parse_pushInst_and_Index - 16 +16 zbc_parse_expr 1818 1816 -2 xc_parse_pushIndex 65 61 -4 zbc_parse_pushSTR 63 58 -5 zbc_parse_name 448 442 -6 xc_parse_pushNUM 74 67 -7 zdc_parse_expr 479 470 -9 bc_parse_pushJUMP_ZERO 21 12 -9 bc_parse_pushJUMP 21 12 -9 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/8 up/down: 16/-51) Total: -35 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index cef0637bf..8e0069658 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -3497,11 +3497,11 @@ static BC_STATUS zdc_lex_token(void)
#define zdc_lex_token(...) (zdc_lex_token(__VA_ARGS__) COMMA_SUCCESS)
#endif // ENABLE_DC
-static void xc_parse_push(char i)
+static void xc_parse_push(unsigned i)
{
BcVec *code = &G.prs.func->code;
dbg_compile("%s:%d pushing bytecode %zd:%d", __func__, __LINE__, code->len, i);
- bc_vec_pushByte(code, i);
+ bc_vec_pushByte(code, (uint8_t)i);
}
static void xc_parse_pushName(char *name)
@@ -3556,17 +3556,21 @@ static void xc_parse_pushIndex(size_t idx)
} while (idx != 0);
}
+static void xc_parse_pushInst_and_Index(unsigned inst, size_t idx)
+{
+ xc_parse_push(inst);
+ xc_parse_pushIndex(idx);
+}
+
#if ENABLE_BC
static void bc_parse_pushJUMP(size_t idx)
{
- xc_parse_push(BC_INST_JUMP);
- xc_parse_pushIndex(idx);
+ xc_parse_pushInst_and_Index(BC_INST_JUMP, idx);
}
static void bc_parse_pushJUMP_ZERO(size_t idx)
{
- xc_parse_push(BC_INST_JUMP_ZERO);
- xc_parse_pushIndex(idx);
+ xc_parse_pushInst_and_Index(BC_INST_JUMP_ZERO, idx);
}
static BC_STATUS zbc_parse_pushSTR(void)
@@ -3574,8 +3578,7 @@ static BC_STATUS zbc_parse_pushSTR(void)
BcParse *p = &G.prs;
char *str = xstrdup(p->lex_strnumbuf.v);
- xc_parse_push(XC_INST_STR);
- xc_parse_pushIndex(p->func->strs.len);
+ xc_parse_pushInst_and_Index(XC_INST_STR, p->func->strs.len);
bc_vec_push(&p->func->strs, &str);
RETURN_STATUS(zxc_lex_next());
@@ -3594,8 +3597,7 @@ static void xc_parse_pushNUM(void)
#else // DC
size_t idx = bc_vec_push(&G.prog.consts, &num);
#endif
- xc_parse_push(XC_INST_NUM);
- xc_parse_pushIndex(idx);
+ xc_parse_pushInst_and_Index(XC_INST_NUM, idx);
}
static BC_STATUS zxc_parse_text_init(const char *text)
@@ -3815,8 +3817,7 @@ static BC_STATUS zbc_parse_params(uint8_t flags)
}
}
- xc_parse_push(BC_INST_CALL);
- xc_parse_pushIndex(nparams);
+ xc_parse_pushInst_and_Index(BC_INST_CALL, nparams);
RETURN_STATUS(BC_STATUS_SUCCESS);
}
@@ -4934,8 +4935,7 @@ static void dc_parse_string(void)
dbg_lex_enter("%s:%d entered", __func__, __LINE__);
str = xstrdup(p->lex_strnumbuf.v);
- xc_parse_push(XC_INST_STR);
- xc_parse_pushIndex(len);
+ xc_parse_pushInst_and_Index(XC_INST_STR, len);
bc_vec_push(&G.prog.strs, &str);
// Explanation needed here