diff options
author | Denys Vlasenko | 2018-12-12 23:03:10 +0100 |
---|---|---|
committer | Denys Vlasenko | 2018-12-12 23:03:10 +0100 |
commit | c0ef23ca400012ca0f4c1cd098e32b685e8f4f09 (patch) | |
tree | 28e45222edb2bf49337e67dc70332ece50005b35 /miscutils | |
parent | 19f110751d333bc4ddb74b8d23b25516d649986c (diff) | |
download | busybox-c0ef23ca400012ca0f4c1cd098e32b685e8f4f09.zip busybox-c0ef23ca400012ca0f4c1cd098e32b685e8f4f09.tar.gz |
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>
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/bc.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 1bf3e37..630a343 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c @@ -617,12 +617,8 @@ struct BcParse; struct BcProgram; -typedef BC_STATUS (*BcParseParse)(struct BcParse *) FAST_FUNC; - typedef struct BcParse { - BcParseParse parse; - BcLex l; BcVec flags; @@ -3483,6 +3479,17 @@ static void bc_parse_number(BcParse *p, BcInst *prev, size_t *nexs) (*prev) = BC_INST_NUM; } +static BC_STATUS zbc_parse_parse(BcParse *p); +static BC_STATUS zdc_parse_parse(BcParse *p); + +static BC_STATUS zcommon_parse(BcParse *p) +{ + if (IS_BC) { + IF_BC(RETURN_STATUS(zbc_parse_parse(p));) + } + IF_DC(RETURN_STATUS(zdc_parse_parse(p));) +} + static BC_STATUS zbc_parse_text(BcParse *p, const char *text) { BcStatus s; @@ -3492,7 +3499,7 @@ static BC_STATUS zbc_parse_text(BcParse *p, const char *text) if (!text[0] && !BC_PARSE_CAN_EXEC(p)) { p->l.t.t = BC_LEX_INVALID; s = BC_STATUS_SUCCESS; - ERROR_RETURN(s =) p->parse(p); + ERROR_RETURN(s =) zcommon_parse(p); if (s) RETURN_STATUS(s); if (!BC_PARSE_CAN_EXEC(p)) RETURN_STATUS(bc_error("file is not executable")); @@ -3556,8 +3563,7 @@ static void bc_parse_free(BcParse *p) bc_lex_free(&p->l); } -static void bc_parse_create(BcParse *p, size_t func, - BcParseParse parse, BcLexNext next) +static void bc_parse_create(BcParse *p, size_t func, BcLexNext next) { memset(p, 0, sizeof(BcParse)); @@ -3568,7 +3574,6 @@ static void bc_parse_create(BcParse *p, size_t func, bc_vec_pushZeroByte(&p->flags); bc_vec_init(&p->ops, sizeof(BcLexType), NULL); - p->parse = parse; // p->auto_part = p->nbraces = 0; - already is bc_parse_updateFunc(p, func); } @@ -4630,7 +4635,7 @@ static BC_STATUS zbc_parse_stmt(BcParse *p) # define zbc_parse_stmt(...) (zbc_parse_stmt(__VA_ARGS__), BC_STATUS_SUCCESS) #endif -static FAST_FUNC BC_STATUS zbc_parse_parse(BcParse *p) +static BC_STATUS zbc_parse_parse(BcParse *p) { BcStatus s; @@ -4930,7 +4935,7 @@ static BC_STATUS zbc_parse_expr(BcParse *p, uint8_t flags, BcParseNext next) static void bc_parse_init(BcParse *p, size_t func) { - bc_parse_create(p, func, zbc_parse_parse, zbc_lex_token); + bc_parse_create(p, func, zbc_lex_token); } static 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) # define zdc_parse_expr(...) (zdc_parse_expr(__VA_ARGS__), BC_STATUS_SUCCESS) #endif -static FAST_FUNC BC_STATUS zdc_parse_parse(BcParse *p) +static BC_STATUS zdc_parse_parse(BcParse *p) { BcStatus s; @@ -5156,7 +5161,7 @@ static FAST_FUNC BC_STATUS zdc_parse_parse(BcParse *p) static void dc_parse_init(BcParse *p, size_t func) { - bc_parse_create(p, func, zdc_parse_parse, zdc_lex_token); + bc_parse_create(p, func, zdc_lex_token); } #endif // ENABLE_DC @@ -7011,7 +7016,7 @@ static BC_STATUS zbc_vm_process(const char *text) if (s) RETURN_STATUS(s); while (G.prs.l.t.t != BC_LEX_EOF) { - ERROR_RETURN(s =) G.prs.parse(&G.prs); + ERROR_RETURN(s =) zcommon_parse(&G.prs); if (s) RETURN_STATUS(s); } @@ -7347,7 +7352,7 @@ static BC_STATUS zbc_vm_exec(void) if (DEBUG_LIB && s) RETURN_STATUS(s); while (G.prs.l.t.t != BC_LEX_EOF) { - ERROR_RETURN(s =) G.prs.parse(&G.prs); + ERROR_RETURN(s =) zcommon_parse(&G.prs); if (DEBUG_LIB && s) RETURN_STATUS(s); } s = zbc_program_exec(); |