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 fee2c2e9705b33034010f742a05f39985958efbc Author: chao an <[email protected]> AuthorDate: Wed Oct 28 16:57:19 2026 +0800 libc/stdio: Batch vsprintf literal output Write consecutive literal format text with one stream call when ROMGETC is not required, reducing per-character output overhead on printf hot paths. Signed-off-by: chao an <[email protected]> --- libs/libc/stream/lib_libvsprintf.c | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/libs/libc/stream/lib_libvsprintf.c b/libs/libc/stream/lib_libvsprintf.c index d22c1931c3e..7a166eebc49 100644 --- a/libs/libc/stream/lib_libvsprintf.c +++ b/libs/libc/stream/lib_libvsprintf.c @@ -181,6 +181,60 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream, for (; ; ) { +#ifndef CONFIG_ARCH_ROMGETC + FAR const char *start = fmt; + + for (; ; ) + { + c = fmt_char(fmt); + if (c == '\0') + { +#ifdef CONFIG_LIBC_NUMBERED_ARGS + if (stream != NULL) +#endif + { + size_t len = (fmt - start) - 1; + + if (len > 0) + { + stream_puts(start, len, stream); + } + } + + goto ret; + } + + if (c == '%') + { + size_t len = (fmt - start) - 1; + + c = fmt_char(fmt); + if (c != '%') + { +#ifdef CONFIG_LIBC_NUMBERED_ARGS + if (stream != NULL) +#endif + { + if (len > 0) + { + stream_puts(start, len, stream); + } + } + + break; + } + +#ifdef CONFIG_LIBC_NUMBERED_ARGS + if (stream != NULL) +#endif + { + stream_puts(start, len + 1, stream); + } + + start = fmt; + } + } +#else for (; ; ) { c = fmt_char(fmt); @@ -207,6 +261,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream, stream_putc(c, stream); #endif } +#endif flags = 0; width = 0;
