diff options
author | Denys Vlasenko | 2021-06-29 03:44:56 +0200 |
---|---|---|
committer | Denys Vlasenko | 2021-06-29 03:44:56 +0200 |
commit | 216d3d8ad9b7d0346cf439ccaca18d0a263e7608 (patch) | |
tree | 0443eaf8ae59335199f10bdadb76dd49acbd59c0 /editors | |
parent | 4f27503a1ecab8dfe373a349df3d8fe3c22e2160 (diff) | |
download | busybox-216d3d8ad9b7d0346cf439ccaca18d0a263e7608.zip busybox-216d3d8ad9b7d0346cf439ccaca18d0a263e7608.tar.gz |
awk: code shrink
function old new delta
parse_expr 948 945 -3
chain_expr 65 62 -3
chain_group 655 649 -6
parse_program 310 303 -7
rollback_token 10 - -10
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/4 up/down: 0/-29) Total: -29 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-rw-r--r-- | editors/awk.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/editors/awk.c b/editors/awk.c index fb1e5d5..3d1c04a 100644 --- a/editors/awk.c +++ b/editors/awk.c @@ -1300,7 +1300,7 @@ static uint32_t next_token(uint32_t expected) #undef save_info } -static void rollback_token(void) +static ALWAYS_INLINE void rollback_token(void) { t_rollback = TRUE; } @@ -1474,14 +1474,14 @@ static node *parse_expr(uint32_t term_tc) case TC_LENGTH: debug_printf_parse("%s: TC_LENGTH\n", __func__); - next_token(TC_LPAREN /* length(...) */ + tc = next_token(TC_LPAREN /* length(...) */ | TS_OPTERM /* length; (or newline)*/ | TC_GRPTERM /* length } */ | TC_BINOPX /* length <op> NUM */ | TC_COMMA /* print length, 1 */ ); rollback_token(); - if (t_tclass & TC_LPAREN) { + if (tc & TC_LPAREN) { /* It was a "(" token. Handle just like TC_BUILTIN */ cn->l.n = parse_lrparen_list(); } @@ -1563,19 +1563,23 @@ static void chain_group(void) if (c & TC_GRPSTART) { debug_printf_parse("%s: TC_GRPSTART\n", __func__); - while (next_token(TS_GRPSEQ | TC_GRPTERM) != TC_GRPTERM) { + while ((c = next_token(TS_GRPSEQ | TC_GRPTERM)) != TC_GRPTERM) { debug_printf_parse("%s: !TC_GRPTERM\n", __func__); - if (t_tclass & TC_NEWLINE) + if (c & TC_NEWLINE) continue; rollback_token(); chain_group(); } debug_printf_parse("%s: TC_GRPTERM\n", __func__); - } else if (c & (TS_OPSEQ | TS_OPTERM)) { + return; + } + if (c & (TS_OPSEQ | TS_OPTERM)) { debug_printf_parse("%s: TS_OPSEQ | TS_OPTERM\n", __func__); rollback_token(); chain_expr(OC_EXEC | Vx); - } else { + return; + } + { /* TS_STATEMNT */ debug_printf_parse("%s: TS_STATEMNT(?)\n", __func__); switch (t_info & OPCLSMASK) { |