aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-01-09 11:17:19 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2019-01-09 11:17:19 +0100
commitcfc2546ea4be9828acf936231386edc404cb502f (patch)
tree9a085f6f17dd54a458604b78d55d91f8e588136f /miscutils
parenta1698a15dc93e429732d513ecfa3f1be723b51c5 (diff)
downloadbusybox-cfc2546ea4be9828acf936231386edc404cb502f.tar.gz
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>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/bc.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index a34312851..7fecb264d 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