aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-06-29 03:44:56 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-06-29 03:44:56 +0200
commit216d3d8ad9b7d0346cf439ccaca18d0a263e7608 (patch)
tree0443eaf8ae59335199f10bdadb76dd49acbd59c0
parent4f27503a1ecab8dfe373a349df3d8fe3c22e2160 (diff)
downloadbusybox-w32-216d3d8ad9b7d0346cf439ccaca18d0a263e7608.tar.gz
busybox-w32-216d3d8ad9b7d0346cf439ccaca18d0a263e7608.tar.bz2
busybox-w32-216d3d8ad9b7d0346cf439ccaca18d0a263e7608.zip
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>
-rw-r--r--editors/awk.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/editors/awk.c b/editors/awk.c
index fb1e5d59b..3d1c04a32 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -1300,7 +1300,7 @@ static uint32_t next_token(uint32_t expected)
1300#undef save_info 1300#undef save_info
1301} 1301}
1302 1302
1303static void rollback_token(void) 1303static ALWAYS_INLINE void rollback_token(void)
1304{ 1304{
1305 t_rollback = TRUE; 1305 t_rollback = TRUE;
1306} 1306}
@@ -1474,14 +1474,14 @@ static node *parse_expr(uint32_t term_tc)
1474 1474
1475 case TC_LENGTH: 1475 case TC_LENGTH:
1476 debug_printf_parse("%s: TC_LENGTH\n", __func__); 1476 debug_printf_parse("%s: TC_LENGTH\n", __func__);
1477 next_token(TC_LPAREN /* length(...) */ 1477 tc = next_token(TC_LPAREN /* length(...) */
1478 | TS_OPTERM /* length; (or newline)*/ 1478 | TS_OPTERM /* length; (or newline)*/
1479 | TC_GRPTERM /* length } */ 1479 | TC_GRPTERM /* length } */
1480 | TC_BINOPX /* length <op> NUM */ 1480 | TC_BINOPX /* length <op> NUM */
1481 | TC_COMMA /* print length, 1 */ 1481 | TC_COMMA /* print length, 1 */
1482 ); 1482 );
1483 rollback_token(); 1483 rollback_token();
1484 if (t_tclass & TC_LPAREN) { 1484 if (tc & TC_LPAREN) {
1485 /* It was a "(" token. Handle just like TC_BUILTIN */ 1485 /* It was a "(" token. Handle just like TC_BUILTIN */
1486 cn->l.n = parse_lrparen_list(); 1486 cn->l.n = parse_lrparen_list();
1487 } 1487 }
@@ -1563,19 +1563,23 @@ static void chain_group(void)
1563 1563
1564 if (c & TC_GRPSTART) { 1564 if (c & TC_GRPSTART) {
1565 debug_printf_parse("%s: TC_GRPSTART\n", __func__); 1565 debug_printf_parse("%s: TC_GRPSTART\n", __func__);
1566 while (next_token(TS_GRPSEQ | TC_GRPTERM) != TC_GRPTERM) { 1566 while ((c = next_token(TS_GRPSEQ | TC_GRPTERM)) != TC_GRPTERM) {
1567 debug_printf_parse("%s: !TC_GRPTERM\n", __func__); 1567 debug_printf_parse("%s: !TC_GRPTERM\n", __func__);
1568 if (t_tclass & TC_NEWLINE) 1568 if (c & TC_NEWLINE)
1569 continue; 1569 continue;
1570 rollback_token(); 1570 rollback_token();
1571 chain_group(); 1571 chain_group();
1572 } 1572 }
1573 debug_printf_parse("%s: TC_GRPTERM\n", __func__); 1573 debug_printf_parse("%s: TC_GRPTERM\n", __func__);
1574 } else if (c & (TS_OPSEQ | TS_OPTERM)) { 1574 return;
1575 }
1576 if (c & (TS_OPSEQ | TS_OPTERM)) {
1575 debug_printf_parse("%s: TS_OPSEQ | TS_OPTERM\n", __func__); 1577 debug_printf_parse("%s: TS_OPSEQ | TS_OPTERM\n", __func__);
1576 rollback_token(); 1578 rollback_token();
1577 chain_expr(OC_EXEC | Vx); 1579 chain_expr(OC_EXEC | Vx);
1578 } else { 1580 return;
1581 }
1582 {
1579 /* TS_STATEMNT */ 1583 /* TS_STATEMNT */
1580 debug_printf_parse("%s: TS_STATEMNT(?)\n", __func__); 1584 debug_printf_parse("%s: TS_STATEMNT(?)\n", __func__);
1581 switch (t_info & OPCLSMASK) { 1585 switch (t_info & OPCLSMASK) {