Re: [PATCHv3 1/2] lib: vsprintf: optimised put_dec() function

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Denys Vlasenko
Date: Wednesday, August 11, 2010 - 3:43 pm

On Wednesday 11 August 2010 23:58, Michal Nazarewicz wrote:

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).



Bug. You need to use temporary variable to store q / 10000 result.

-- 
vda
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCHv3 1/2] lib: vsprintf: optimised put_dec() function, Michal Nazarewicz, (Wed Aug 11, 2:58 pm)
[PATCHv3 2/2] lib: vsprintf: added a put_dec() test and be ..., Michal Nazarewicz, (Wed Aug 11, 2:58 pm)
Re: [PATCHv3 1/2] lib: vsprintf: optimised put_dec() function, Denys Vlasenko, (Wed Aug 11, 3:43 pm)