[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <308b7158-7c2a-cc98-6091-14dae2b2cbba@rasmusvillemoes.dk>
Date: Tue, 11 Jan 2022 11:26:21 +0100
From: Rasmus Villemoes <linux@...musvillemoes.dk>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Petr Mladek <pmladek@...e.com>, linux-kernel@...r.kernel.org
Cc: Steven Rostedt <rostedt@...dmis.org>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Sakari Ailus <sakari.ailus@...ux.intel.com>
Subject: Re: [PATCH v1 1/1] vsprintf: Move space out of string literals in
fourcc_string()
On 10/01/2022 21.55, Andy Shevchenko wrote:
> The literals "big-endian" and "little-endian" may be potentially
> occurred in other places. Dropping space allows compiler to
> "compress" them by using only a single copy.
Nit: it's not the compiler which does that, but the linker.
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index b02f01366acb..5818856d5626 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -1780,7 +1780,8 @@ char *fourcc_string(char *buf, char *end, const u32 *fourcc,
> *p++ = isascii(c) && isprint(c) ? c : '.';
> }
>
> - strcpy(p, orig & BIT(31) ? " big-endian" : " little-endian");
> + *p++ = ' ';
> + strcpy(p, orig & BIT(31) ? "big-endian" : "little-endian");
> p += strlen(p);
Hm, ok, those two strings do occur a lot with of_property_read_bool()
and friends. But if you're micro-optimizing anyway, why not drop the
strlen() and say p = stpcpy(...) instead?
Rasmus
Powered by blists - more mailing lists