hush: code shrink
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 6 Mar 2018 16:21:57 +0000 (17:21 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 6 Mar 2018 16:21:57 +0000 (17:21 +0100)
function                                             old     new   delta
run_pipe                                            1589    1591      +2
pseudo_exec_argv                                     374     375      +1
builtin_type                                         114     115      +1
find_function                                          8       -      -8
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 3/0 up/down: 4/-8)               Total: -4 bytes

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

index 762cc3fe4f520760f152ac82a9e6d04629a69ba2..6e64efb70051f559640c449eb4035a4966af1f56 100644 (file)
@@ -7181,21 +7181,22 @@ static const struct built_in_command *find_builtin(const char *name)
 #if ENABLE_HUSH_FUNCTIONS
 static struct function **find_function_slot(const char *name)
 {
+       struct function *funcp;
        struct function **funcpp = &G.top_func;
-       while (*funcpp) {
-               if (strcmp(name, (*funcpp)->name) == 0) {
+
+       while ((funcp = *funcpp) != NULL) {
+               if (strcmp(name, funcp->name) == 0) {
+                       debug_printf_exec("found function '%s'\n", name);
                        break;
                }
-               funcpp = &(*funcpp)->next;
+               funcpp = &funcp->next;
        }
        return funcpp;
 }
 
-static const struct function *find_function(const char *name)
+static ALWAYS_INLINE const struct function *find_function(const char *name)
 {
        const struct function *funcp = *find_function_slot(name);
-       if (funcp)
-               debug_printf_exec("found function '%s'\n", name);
        return funcp;
 }