printf icon indicating copy to clipboard operation
printf copied to clipboard

Code fix / improvements

Open ledvinap opened this issue 6 years ago • 3 comments

Apply some changes to existing code. Split into separate commits with comments

ledvinap avatar May 13 '19 19:05 ledvinap

Codecov Report

Merging #60 into master will decrease coverage by 1.37%. The diff coverage is 93.82%.

Impacted file tree graph

@@            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 data Powered by Codecov. Last update 21eea6c...e29f0f8. Read the comment docs.

codecov-io avatar May 13 '19 19:05 codecov-io

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 avatar May 17 '19 19:05 axiomlegend

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

ledvinap avatar May 18 '19 13:05 ledvinap