vsprintf: uninline simple_strntoull(), reorder arguments
A message that is not in the archive (sent off-list or not yet received): 82a2af6e-9b6c-4a09-89d7-ca90cc1cdad1@p183
Andy Shevchenko
Reviewed-byQuoted 6 lines · Alexey Dobriyan
* uninline
simple_strntoull(),
gcc overinlines and this function is not performance critical* reorder arguments, so that appending
INT_MAXas 4th argument generates very efficient tail call
Quoted 8 lines
Space savings:
add/remove: 1/0 grow/shrink: 0/3 up/down: 27/-179 (-152)
Function old new delta
simple_strntoll- 27 +27
simple_strtoull15 10 -5
simple_strtoll41 7 -34
vsscanf 1930 1790 -140
Makes sense to me
...
Review
Quoted 12 lines
(quoted diff) +4
-6if (is_sign) - val.s = simple_strntoll(str, - field_width >= 0 ? field_width : INT_MAX, - &next, base); + val.s = simple_strntoll(str, &next, base, + field_width >= 0 ? field_width : INT_MAX); else - val.u = simple_strntoull(str, - field_width >= 0 ? field_width : INT_MAX, - &next, base); + val.u = simple_strntoull(str, &next, base, + field_width >= 0 ? field_width : INT_MAX);
Looking at these, why do we even care about signedness? field_witdh IIRC is 16-bit or less and if size_t is to big it's still fine. No?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Petr Mladek
Reviewed-byQuoted 8 lines · Alexey Dobriyan
* uninline
simple_strntoull(),
gcc overinlines and this function is not performance critical* reorder arguments, so that appending
INT_MAXas 4th argument generates very efficient tail callSpace savings:
Quoted 8 lines
add/remove: 1/0 grow/shrink: 0/3 up/down: 27/-179 (-152)
Function old new delta
simple_strntoll- 27 +27
simple_strtoull15 10 -5
simple_strtoll41 7 -34
vsscanf 1930 1790 -140Signed-off-by Alexey Dobriyan <[email protected]>
I am usually quite skeptical about these micro-optimizations. They might help only on some architectures with some compiler versions. And they might make it worse for others.
Well, I could imagine that passing constant via the last parameter might help in most cases. And the new ordering of the parameters is fine. So let's get it in.
I have just pushed the patch into printk/linux.git, branch for-6.7.
Best Regards,
Petr