From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: George Spelvin <linux@sciencehorizons.net>
Cc: bjorn@mork.no, linux-kernel@vger.kernel.org,
matt@codeblueprint.co.uk, rv@rasmusvillemoes.dk
Subject: Re: [PATCH v2 1/2] lib/vsprintf.c: Simplify uuid_string()
Date: Sun, 05 Jun 2016 17:22:56 +0300 [thread overview]
Message-ID: <1465136576.1767.59.camel@linux.intel.com> (raw)
In-Reply-To: <20160604051411.3635.qmail@ns.sciencehorizons.net>
On Sat, 2016-06-04 at 01:14 -0400, George Spelvin wrote:
> Rather than have a second pass to upcase the buffer, just make the
> hex lookup table a variable.
>
> Removing the conditional branch from the inner loop is also a
> speedup, but since this is not hot code, the important factor
> it shrinks both source and compiled forms:
>
> Before After Delta Percentage
> x86-32 245 199 -46 -18.8%
> x86-64 246 186 -60 -24.4%
> arm 292 264 -28 -9.6%
> thumb 220 160 -60 -27.3%
> arm64 296 244 -52 -17.6%
>
> Signed-off-by: George Spelvin <linux@horizon.com>
> ---
> lib/vsprintf.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 7332a5d7..4ee07e89 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -1316,24 +1316,24 @@ char *uuid_string(char *buf, char *end, const
> u8 *addr,
> char *p = uuid;
> int i;
> const u8 *index = uuid_be_index;
> - bool uc = false;
> + const char *hex = hex_asc;
>
> - switch (*(++fmt)) {
> + switch (fmt[1]) {
> case 'L':
> - uc = true; /* fall-through */
> + hex = hex_asc_upper; /* fall-through */
> case 'l':
> index = uuid_le_index;
> break;
> case 'B':
> - uc = true;
> + hex = hex_asc_upper;
> break;
> }
>
> for (i = 0; i < 16; i++) {
> - if (uc)
> - p = hex_byte_pack_upper(p, addr[index[i]]);
> - else
> - p = hex_byte_pack(p, addr[index[i]]);
> + u8 byte = addr[index[i]];
> +
> + *p++ = hex[byte >> 4];
> + *p++ = hex[byte & 0x0f];
And what prevents you to assign hex_byte_pack()/hex_byte_pack_upper()
and do one call here?
> switch (i) {
> case 3:
> case 5:
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
next prev parent reply other threads:[~2016-06-05 14:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1464952090.1767.34.camel@linux.intel.com>
2016-06-04 5:13 ` [PATCH v2 0/2] Clean up and shrink uuid input & output George Spelvin
2016-06-04 5:14 ` [PATCH v2 1/2] lib/vsprintf.c: Simplify uuid_string() George Spelvin
2016-06-05 14:22 ` Andy Shevchenko [this message]
2016-06-05 19:57 ` George Spelvin
2016-06-04 5:14 ` [PATCH v2 2/2] lib/uuid.c: eliminate uuid_[bl]e_index arrays George Spelvin
2016-06-04 5:42 ` kbuild test robot
2016-06-04 16:29 ` Joe Perches
2016-06-04 21:57 ` George Spelvin
2016-06-05 14:19 ` Andy Shevchenko
2016-06-05 15:34 ` Joe Perches
2016-06-05 16:15 ` Andy Shevchenko
2016-06-04 13:16 ` [PATCH v2 3/2] lib/uuid.c: Silence an unchecked return value warning George Spelvin
2016-06-05 14:21 ` Andy Shevchenko
2016-06-05 19:25 ` George Spelvin
2016-06-06 8:24 ` Andy Shevchenko
2016-06-07 16:43 ` George Spelvin
2016-06-07 17:13 ` Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1465136576.1767.59.camel@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=bjorn@mork.no \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@sciencehorizons.net \
--cc=matt@codeblueprint.co.uk \
--cc=rv@rasmusvillemoes.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).