[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <xa1t4nmncw03.fsf@mina86.com>
Date: Mon, 24 Sep 2012 16:53:48 +0200
From: Michal Nazarewicz <mpn@...gle.com>
To: George Spelvin <linux@...izon.com>, akpm@...ux-foundation.org,
linux@...izon.com, rabin@....in
Cc: hughd@...gle.com, linux-kernel@...r.kernel.org,
vda.linux@...glemail.com
Subject: Re: [PATCH 3/4] lib: vsprintf: Optimize put_dec_trunc8
On Mon, Sep 24 2012, George Spelvin wrote:
> The fix is straightforward:
>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index e755083..9872855 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -180,8 +180,6 @@ char *put_dec_trunc8(char *buf, unsigned r)
> *buf++ = q - 10*r;
> }
>
> - if (r == 0)
> - return buf;
> q = (r * 0x199a) >> 16; /* r <= 9999 */
> *buf++ = (r - 10 * q) + '0';
> if (q == 0)
>
> Inspired by Michal Nazarewicz, I have some ideas for more tweaking to
> that code.
Ah, right. I also thought about that first but than started worrying
that it could produce unnecessary zeros if the loop iterates at least
once and exits with r being zero, but now I see that this cannot happen
since if the loop condition was true, r >= 10000 and it has been divided
by 10000 in the loop so now it's at least 1.
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +----<email/xmpp: mpn@...gle.com>--------------ooO--(_)--Ooo--
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists