This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit c27da7e436afb46648d079a912689de2d127328c Author: chao an <[email protected]> AuthorDate: Mon Nov 2 11:41:11 2026 +0800 libc/stdio: Batch float mantissa digits The exponent-style floating point path writes the mantissa fraction one byte at a time. Write the available dtoa digits with one stream call and use the repeat helper for any precision padding zeroes to avoid per-digit putc callbacks. Signed-off-by: chao an <[email protected]> --- libs/libc/stream/lib_libvsprintf.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libs/libc/stream/lib_libvsprintf.c b/libs/libc/stream/lib_libvsprintf.c index fcc0d36f653..b2362001b54 100644 --- a/libs/libc/stream/lib_libvsprintf.c +++ b/libs/libc/stream/lib_libvsprintf.c @@ -937,13 +937,19 @@ flt_oper: stream_putc(_dtoa.digits[0], stream); if (prec > 0) { - uint8_t pos; + int nbytes; stream_putc('.', stream); - for (pos = 1; pos < 1 + prec; pos++) + + nbytes = MIN(prec, ndigs > 1 ? ndigs - 1 : 0); + if (nbytes > 0) + { + stream_puts(&_dtoa.digits[1], nbytes, stream); + } + + if (prec > nbytes) { - stream_putc(pos < ndigs ? _dtoa.digits[pos] : '0', - stream); + stream_repeat('0', prec - nbytes, stream); } } else if ((flags & FL_ALT) != 0)
