[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH 1/4] procps: code shrink
From: Denys Vlasenko <vda.linux () googlemail ! com>
Date: 2020-06-29 14:09:15
Message-ID: CAK1hOcPnBa22MmeBHr+dfMUbT7CMaR3FzyEoc2LWehv2SHmX0A () mail ! gmail ! com
[Download RAW message or body]
Applied, thanks
On Thu, Jun 11, 2020 at 3:45 PM Martin Lewis <martin.lewis.x84@gmail.com> wrote:
>
> function old new delta
> skip_whitespace_if_prefixed_with - 37 +37
> procps_read_smaps 954 841 -113
> ------------------------------------------------------------------------------
> (add/remove: 1/0 grow/shrink: 0/1 up/down: 37/-113) Total: -76 bytes
> text data bss dec hex filename
> 981418 16915 1872 1000205 f430d busybox_old
> 981342 16915 1872 1000129 f42c1 busybox_unstripped
>
> Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
> ---
> libbb/procps.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/libbb/procps.c b/libbb/procps.c
> index af3ad86ff..c7ce45977 100644
> --- a/libbb/procps.c
> +++ b/libbb/procps.c
> @@ -177,6 +177,15 @@ static char *skip_fields(char *str, int count)
> }
> #endif
>
> +static int skip_whitespace_if_prefixed_with(char *buf, const char *prefix, char **tp) {
> + *tp = is_prefixed_with(buf, prefix);
> + if (*tp) {
> + *tp = skip_whitespace(*tp);
> + return TRUE;
> + }
> + return FALSE;
> +}
> +
> #if ENABLE_FEATURE_TOPMEM || ENABLE_PMAP
> int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total,
> void (*cb)(struct smaprec *, void *), void *data)
> @@ -207,8 +216,7 @@ int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total,
> char *tp, *p;
>
> #define SCAN(S, X) \
> - if ((tp = is_prefixed_with(buf, S)) != NULL) { \
> - tp = skip_whitespace(tp); \
> + if (skip_whitespace_if_prefixed_with(buf, S, &tp)) { \
> total->X += currec.X = fast_strtoul_10(&tp); \
> continue; \
> }
> --
> 2.11.0
>
> _______________________________________________
> 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