[libc] Rewrite vfprintf.c and tiny_printf.c to use __divmod for speed #2012
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
More in a series of speeding up numeric-to-string conversions in the C library. This PR adds the fast __divmod calculation to vfprintf/sprintf/printf.c and tiny_printf.c.
Although few on faster systems are likely to notice speed improvements, those with 8086/8088 CPUs may start to see a difference when running ANSI sequence intensive terminal applications like
sl
,ttyclock
,matrix
and the like. This is because for every cursor position as well as any color sequence, a number has to get converted to a string through these routines, and then converted back to the same number by the ANSI console driver. It wasn't realized until recently how much time these conversions were taking on systems with very slow DIV instructions - all 8086/8088s and early CPUs.The ANSI console speedups are coming next, then it might be worth measuring any speedups. @Vutshi, hopefully this will help your older system run
sl
andttyclock
much quicker than before, but we will see!