From: Denys Vlasenko <vda.linux@googlemail.com>
To: Michal Nazarewicz <mina86@mina86.com>
Cc: linux-kernel@vger.kernel.org, m.nazarewicz@samsung.com,
Andrew Morton <akpm@linux-foundation.org>,
"Douglas W. Jones" <jones@cs.uiowa.edu>
Subject: Re: [PATCHv3 1/2] lib: vsprintf: optimised put_dec() function
Date: Thu, 12 Aug 2010 00:43:34 +0200 [thread overview]
Message-ID: <201008120043.34081.vda.linux@googlemail.com> (raw)
In-Reply-To: <1bec965de7de10bf9cddda988a2eaaf755852919.1281532502.git.mina86@mina86.com>
On Wednesday 11 August 2010 23:58, Michal Nazarewicz wrote:
> +static noinline_for_stack
> +char *put_dec(char *buf, unsigned long long n)
> +{
> + uint32_t d3, d2, d1, q;
> +
> + if (n < 10) {
> + *buf++ = '0' + (unsigned)n;
> + return buf;
> + }
I looked at it and discovered that 0 is already special-cased
at put_dec() callsite. You can drop the above if() block
(or better comment it out, explaining that caller does it),
and while at it, improve special-case code in number():
replace
/* generate full string in tmp[], in reverse order */
i = 0;
if (num == 0)
tmp[i++] = '0';
with
if (num <= 7)
tmp[i++] = '0' + num;
(7, not 9, because it can be an octal conversion).
> + q = q / 10000;
> + buf = put_dec_full4(buf, q % 10000);
Bug. You need to use temporary variable to store q / 10000 result.
--
vda
prev parent reply other threads:[~2010-08-11 22:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-11 21:58 [PATCHv3 1/2] lib: vsprintf: optimised put_dec() function Michal Nazarewicz
2010-08-11 21:58 ` [PATCHv3 2/2] lib: vsprintf: added a put_dec() test and benchmark tool Michal Nazarewicz
2010-08-11 22:43 ` Denys Vlasenko [this message]
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=201008120043.34081.vda.linux@googlemail.com \
--to=vda.linux@googlemail.com \
--cc=akpm@linux-foundation.org \
--cc=jones@cs.uiowa.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=m.nazarewicz@samsung.com \
--cc=mina86@mina86.com \
/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