bc: drop zbc_parse_endBody() bool parameter, move its code to caller which uses it
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 14 Dec 2018 22:41:33 +0000 (23:41 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 14 Dec 2018 22:41:33 +0000 (23:41 +0100)
function                                             old     new   delta
zbc_parse_stmt                                      1456    1479     +23
zbc_parse_body                                       103     101      -2
zbc_parse_endBody                                    326     292     -34
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 23/-36)            Total: -13 bytes
   text    data     bss     dec     hex filename
 979893     485    7296  987674   f121a busybox_old
 979880     485    7296  987661   f120d busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/bc.c

index 9a501a25e3228d0b0427a4d1b3c54627d939879d..4024a08df5b34167f1cd95c9aec4059a26ff44ed 100644 (file)
@@ -4046,23 +4046,13 @@ static BC_STATUS zbc_parse_return(BcParse *p)
 # define zbc_parse_return(...) (zbc_parse_return(__VA_ARGS__), BC_STATUS_SUCCESS)
 #endif
 
-static BC_STATUS zbc_parse_endBody(BcParse *p, bool brace)
+static BC_STATUS zbc_parse_endBody(BcParse *p)
 {
        BcStatus s = BC_STATUS_SUCCESS;
 
-       if (p->flags.len <= 1 || (brace && p->nbraces == 0))
+       if (p->flags.len <= 1)
                RETURN_STATUS(bc_error_bad_token());
 
-       if (brace) {
-               if (p->l.t.t != BC_LEX_RBRACE)
-                       RETURN_STATUS(bc_error_bad_token());
-               if (!p->nbraces)
-                       RETURN_STATUS(bc_error_bad_token());
-               --p->nbraces;
-               s = zbc_lex_next(&p->l);
-               if (s) RETURN_STATUS(s);
-       }
-
        if (BC_PARSE_IF(p)) {
                uint8_t *flag_ptr;
 
@@ -4523,7 +4513,7 @@ static BC_STATUS zbc_parse_body(BcParse *p, bool brace)
        else {
                dbg_lex("%s:%d !BC_PARSE_FLAG_FUNC_INNER", __func__, __LINE__);
                s = zbc_parse_stmt(p);
-               if (!s && !brace) s = zbc_parse_endBody(p, false);
+               if (!s && !brace) s = zbc_parse_endBody(p);
        }
 
        dbg_lex_done("%s:%d done", __func__, __LINE__);
@@ -4598,7 +4588,12 @@ static BC_STATUS zbc_parse_stmt(BcParse *p)
                        while (!s && p->l.t.t == BC_LEX_SCOLON) s = zbc_lex_next(&p->l);
                        break;
                case BC_LEX_RBRACE:
-                       s = zbc_parse_endBody(p, true);
+                       if (p->nbraces == 0)
+                               RETURN_STATUS(bc_error_bad_token());
+                       --p->nbraces;
+                       s = zbc_lex_next(&p->l);
+                       if (!s)
+                               s = zbc_parse_endBody(p);
                        break;
                case BC_LEX_STR:
                        s = zbc_parse_string(p, BC_INST_PRINT_STR);