aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-12 23:03:10 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-12 23:03:10 +0100
commitc0ef23ca400012ca0f4c1cd098e32b685e8f4f09 (patch)
tree28e45222edb2bf49337e67dc70332ece50005b35
parent19f110751d333bc4ddb74b8d23b25516d649986c (diff)
downloadbusybox-w32-c0ef23ca400012ca0f4c1cd098e32b685e8f4f09.tar.gz
busybox-w32-c0ef23ca400012ca0f4c1cd098e32b685e8f4f09.tar.bz2
busybox-w32-c0ef23ca400012ca0f4c1cd098e32b685e8f4f09.zip
bc: remove parse function pointer
function old new delta zbc_program_asciify - 372 +372 zcommon_parse - 341 +341 zbc_program_printStream - 141 +141 zbc_program_pushArray - 111 +111 zbc_program_nquit - 92 +92 zbc_vm_process 61 63 +2 zbc_parse_text 122 123 +1 bc_vm_run 591 592 +1 zdc_parse_mem 108 107 -1 zbc_parse_operator 175 174 -1 zbc_parse_else 133 132 -1 zbc_parse_body 104 103 -1 zbc_program_read 261 259 -2 zdc_parse_register 40 37 -3 zbc_parse_string 100 97 -3 zbc_parse_endBody 343 339 -4 zdc_parse_expr 688 680 -8 zbc_parse_auto 198 188 -10 zbc_parse_name 414 401 -13 common_parse_init 45 31 -14 zdc_parse_parse 23 - -23 bc_parse_create 158 131 -27 zbc_parse_stmt 1540 1502 -38 bc_parse_expr_empty_ok 1882 1840 -42 zbc_program_exec 3963 3837 -126 zbc_parse_parse 311 - -311 zbc_program_modexp 556 - -556 ------------------------------------------------------------------------------ (add/remove: 5/3 grow/shrink: 3/16 up/down: 1061/-1184) Total: -123 bytes text data bss dec hex filename 980757 485 7296 988538 f157a busybox_old 980634 485 7296 988415 f14ff busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 1bf3e373e..630a343d1 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -617,12 +617,8 @@ struct BcParse;
617 617
618struct BcProgram; 618struct BcProgram;
619 619
620typedef BC_STATUS (*BcParseParse)(struct BcParse *) FAST_FUNC;
621
622typedef struct BcParse { 620typedef struct BcParse {
623 621
624 BcParseParse parse;
625
626 BcLex l; 622 BcLex l;
627 623
628 BcVec flags; 624 BcVec flags;
@@ -3483,6 +3479,17 @@ static void bc_parse_number(BcParse *p, BcInst *prev, size_t *nexs)
3483 (*prev) = BC_INST_NUM; 3479 (*prev) = BC_INST_NUM;
3484} 3480}
3485 3481
3482static BC_STATUS zbc_parse_parse(BcParse *p);
3483static BC_STATUS zdc_parse_parse(BcParse *p);
3484
3485static BC_STATUS zcommon_parse(BcParse *p)
3486{
3487 if (IS_BC) {
3488 IF_BC(RETURN_STATUS(zbc_parse_parse(p));)
3489 }
3490 IF_DC(RETURN_STATUS(zdc_parse_parse(p));)
3491}
3492
3486static BC_STATUS zbc_parse_text(BcParse *p, const char *text) 3493static BC_STATUS zbc_parse_text(BcParse *p, const char *text)
3487{ 3494{
3488 BcStatus s; 3495 BcStatus s;
@@ -3492,7 +3499,7 @@ static BC_STATUS zbc_parse_text(BcParse *p, const char *text)
3492 if (!text[0] && !BC_PARSE_CAN_EXEC(p)) { 3499 if (!text[0] && !BC_PARSE_CAN_EXEC(p)) {
3493 p->l.t.t = BC_LEX_INVALID; 3500 p->l.t.t = BC_LEX_INVALID;
3494 s = BC_STATUS_SUCCESS; 3501 s = BC_STATUS_SUCCESS;
3495 ERROR_RETURN(s =) p->parse(p); 3502 ERROR_RETURN(s =) zcommon_parse(p);
3496 if (s) RETURN_STATUS(s); 3503 if (s) RETURN_STATUS(s);
3497 if (!BC_PARSE_CAN_EXEC(p)) 3504 if (!BC_PARSE_CAN_EXEC(p))
3498 RETURN_STATUS(bc_error("file is not executable")); 3505 RETURN_STATUS(bc_error("file is not executable"));
@@ -3556,8 +3563,7 @@ static void bc_parse_free(BcParse *p)
3556 bc_lex_free(&p->l); 3563 bc_lex_free(&p->l);
3557} 3564}
3558 3565
3559static void bc_parse_create(BcParse *p, size_t func, 3566static void bc_parse_create(BcParse *p, size_t func, BcLexNext next)
3560 BcParseParse parse, BcLexNext next)
3561{ 3567{
3562 memset(p, 0, sizeof(BcParse)); 3568 memset(p, 0, sizeof(BcParse));
3563 3569
@@ -3568,7 +3574,6 @@ static void bc_parse_create(BcParse *p, size_t func,
3568 bc_vec_pushZeroByte(&p->flags); 3574 bc_vec_pushZeroByte(&p->flags);
3569 bc_vec_init(&p->ops, sizeof(BcLexType), NULL); 3575 bc_vec_init(&p->ops, sizeof(BcLexType), NULL);
3570 3576
3571 p->parse = parse;
3572 // p->auto_part = p->nbraces = 0; - already is 3577 // p->auto_part = p->nbraces = 0; - already is
3573 bc_parse_updateFunc(p, func); 3578 bc_parse_updateFunc(p, func);
3574} 3579}
@@ -4630,7 +4635,7 @@ static BC_STATUS zbc_parse_stmt(BcParse *p)
4630# define zbc_parse_stmt(...) (zbc_parse_stmt(__VA_ARGS__), BC_STATUS_SUCCESS) 4635# define zbc_parse_stmt(...) (zbc_parse_stmt(__VA_ARGS__), BC_STATUS_SUCCESS)
4631#endif 4636#endif
4632 4637
4633static FAST_FUNC BC_STATUS zbc_parse_parse(BcParse *p) 4638static BC_STATUS zbc_parse_parse(BcParse *p)
4634{ 4639{
4635 BcStatus s; 4640 BcStatus s;
4636 4641
@@ -4930,7 +4935,7 @@ static BC_STATUS zbc_parse_expr(BcParse *p, uint8_t flags, BcParseNext next)
4930 4935
4931static void bc_parse_init(BcParse *p, size_t func) 4936static void bc_parse_init(BcParse *p, size_t func)
4932{ 4937{
4933 bc_parse_create(p, func, zbc_parse_parse, zbc_lex_token); 4938 bc_parse_create(p, func, zbc_lex_token);
4934} 4939}
4935 4940
4936static BC_STATUS zbc_parse_expression(BcParse *p, uint8_t flags) 4941static BC_STATUS zbc_parse_expression(BcParse *p, uint8_t flags)
@@ -5134,7 +5139,7 @@ static BC_STATUS zdc_parse_expr(BcParse *p, uint8_t flags)
5134# define zdc_parse_expr(...) (zdc_parse_expr(__VA_ARGS__), BC_STATUS_SUCCESS) 5139# define zdc_parse_expr(...) (zdc_parse_expr(__VA_ARGS__), BC_STATUS_SUCCESS)
5135#endif 5140#endif
5136 5141
5137static FAST_FUNC BC_STATUS zdc_parse_parse(BcParse *p) 5142static BC_STATUS zdc_parse_parse(BcParse *p)
5138{ 5143{
5139 BcStatus s; 5144 BcStatus s;
5140 5145
@@ -5156,7 +5161,7 @@ static FAST_FUNC BC_STATUS zdc_parse_parse(BcParse *p)
5156 5161
5157static void dc_parse_init(BcParse *p, size_t func) 5162static void dc_parse_init(BcParse *p, size_t func)
5158{ 5163{
5159 bc_parse_create(p, func, zdc_parse_parse, zdc_lex_token); 5164 bc_parse_create(p, func, zdc_lex_token);
5160} 5165}
5161 5166
5162#endif // ENABLE_DC 5167#endif // ENABLE_DC
@@ -7011,7 +7016,7 @@ static BC_STATUS zbc_vm_process(const char *text)
7011 if (s) RETURN_STATUS(s); 7016 if (s) RETURN_STATUS(s);
7012 7017
7013 while (G.prs.l.t.t != BC_LEX_EOF) { 7018 while (G.prs.l.t.t != BC_LEX_EOF) {
7014 ERROR_RETURN(s =) G.prs.parse(&G.prs); 7019 ERROR_RETURN(s =) zcommon_parse(&G.prs);
7015 if (s) RETURN_STATUS(s); 7020 if (s) RETURN_STATUS(s);
7016 } 7021 }
7017 7022
@@ -7347,7 +7352,7 @@ static BC_STATUS zbc_vm_exec(void)
7347 if (DEBUG_LIB && s) RETURN_STATUS(s); 7352 if (DEBUG_LIB && s) RETURN_STATUS(s);
7348 7353
7349 while (G.prs.l.t.t != BC_LEX_EOF) { 7354 while (G.prs.l.t.t != BC_LEX_EOF) {
7350 ERROR_RETURN(s =) G.prs.parse(&G.prs); 7355 ERROR_RETURN(s =) zcommon_parse(&G.prs);
7351 if (DEBUG_LIB && s) RETURN_STATUS(s); 7356 if (DEBUG_LIB && s) RETURN_STATUS(s);
7352 } 7357 }
7353 s = zbc_program_exec(); 7358 s = zbc_program_exec();