Code fix / improvements
Apply some changes to existing code. Split into separate commits with comments
Codecov Report
Merging #60 into master will decrease coverage by
1.37%. The diff coverage is93.82%.
@@ Coverage Diff @@
## master #60 +/- ##
==========================================
- Coverage 100% 98.62% -1.38%
==========================================
Files 1 1
Lines 359 363 +4
==========================================
- Hits 359 358 -1
- Misses 0 5 +5
| Impacted Files | Coverage Δ | |
|---|---|---|
| printf.c | 98.62% <93.82%> (-1.38%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 21eea6c...e29f0f8. Read the comment docs.
Calling *out for each character is costly. Consider sprintf functionality. you call *out for every character only to do: if (a < b) a[i] = c; Lot of overhead for a few instructions. Definitely need to put most options to ntoa_format, etc. into a struct vs stack.
@axiomlegend :
Yes, out is quite expensive, but also generic. In a lot of embedded applications output to serial port is (or SWO) desired, and using sprintf will complicate things a lot.
One improvement is to use write semantics for output. Number of calls will be reduced, 1 write between %, 1 call for value output and one (or few chunks) for padding.
Another optimization in my list is to move buffer limit test out of out function, slightly improving performance.