[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH] Rewrite iteration through applet names to save a few bytes
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2016-04-15 20:14:29
Message-ID: CAK1hOcPBxfd1tAQ19XauLEn14fv2KAZ+1oGqtzgFztivg3OYcg () mail ! gmail ! com
[Download RAW message or body]

Applied, thanks!

On Fri, Apr 8, 2016 at 12:57 PM, Ron Yorston <rmy@pobox.com> wrote:
> function                                             old     new   delta
> run_applet_and_exit                                  758     755      -3
> ------------------------------------------------------------------------------
> (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-3)               Total: -3 bytes
>
> In standalone shell mode the saving increases to 17 bytes.
>
> Signed-off-by: Ron Yorston <rmy@pobox.com>
> ---
>  libbb/appletlib.c | 3 ++-
>  libbb/lineedit.c  | 7 +++----
>  shell/ash.c       | 3 ++-
>  3 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/libbb/appletlib.c b/libbb/appletlib.c
> index de654f6..b682e6b 100644
> --- a/libbb/appletlib.c
> +++ b/libbb/appletlib.c
> @@ -791,7 +791,8 @@ static int busybox_main(char **argv)
>                         full_write2_str(a);
>                         full_write2_str("\n");
>                         i++;
> -                       a += strlen(a) + 1;
> +                       while (*a++ != '\0')
> +                               continue;
>                 }
>                 return 0;
>         }
> diff --git a/libbb/lineedit.c b/libbb/lineedit.c
> index 2ddb2b6..3e62f46 100644
> --- a/libbb/lineedit.c
> +++ b/libbb/lineedit.c
> @@ -779,12 +779,11 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type)
>         if (type == FIND_EXE_ONLY) {
>                 const char *p = applet_names;
>
> -               i = 0;
> -               while (i < NUM_APPLETS) {
> +               while (*p) {
>                         if (strncmp(pfind, p, pf_len) == 0)
>                                 add_match(xstrdup(p));
> -                       p += strlen(p) + 1;
> -                       i++;
> +                       while (*p++ != '\0')
> +                               continue;
>                 }
>         }
>  #endif
> diff --git a/shell/ash.c b/shell/ash.c
> index 5613e1f..13eeab3 100644
> --- a/shell/ash.c
> +++ b/shell/ash.c
> @@ -12597,7 +12597,8 @@ helpcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
>                                 out1fmt("\n");
>                                 col = 0;
>                         }
> -                       a += strlen(a) + 1;
> +                       while (*a++ != '\0')
> +                               continue;
>                 }
>         }
>  # endif
> --
> 2.5.5
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic