mirror of
git://git.musl-libc.org/musl
synced 2025-03-06 20:48:29 +01:00
printf decimal integer formatting: shave off one division
once the remaining value is less than 10, the modulo operation to produce the final digit and division to prepare for next loop iteration can be dropped. this may be a meaningful performance distinction when formatting low-magnitude numbers in bulk, and should never hurt. based on patch by Viktor Reznov.
This commit is contained in:
parent
a23cf8f9c5
commit
3f9d4224d8
1 changed files with 2 additions and 1 deletions
|
@ -166,7 +166,8 @@ static char *fmt_u(uintmax_t x, char *s)
|
|||
{
|
||||
unsigned long y;
|
||||
for ( ; x>ULONG_MAX; x/=10) *--s = '0' + x%10;
|
||||
for (y=x; y; y/=10) *--s = '0' + y%10;
|
||||
for (y=x; y>=10; y/=10) *--s = '0' + y%10;
|
||||
if (y) *--s = '0' + y;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue