anchao opened a new pull request, #21072: URL: https://github.com/apache/nuttx/pull/21072
## Summary
This PR optimizes the hot `vsprintf()` formatting path used by
printf/syslog-style output.
It contains two changes:
- Batch consecutive literal format text into a single stream write when
`CONFIG_ARCH_ROMGETC` is not required.
- Batch repeated padding spaces/zeroes using fixed-size chunks instead of
emitting one character at a time.
These reduce per-character output callback overhead in common formatting
paths, especially for log/printf output with long literal text or wide field
padding.
## Motivation
`vsprintf_internal()` currently emits many parts of the formatted output one
character at a time via `lib_stream_putc()`. For printf/syslog hot paths, this
means repeated function-pointer-style output calls for:
- plain literal text in the format string
- left/right field padding
- zero padding for numeric formats
The formatted result is unchanged, but batching these output sequences can
reduce call overhead.
## Implementation
### Literal text batching
For non-`CONFIG_ARCH_ROMGETC` builds, consecutive literal characters in the
format string are now accumulated and emitted with one `stream_puts()` call.
The `CONFIG_ARCH_ROMGETC` path keeps the original character-by-character
behavior because format characters may need to be fetched through
`up_romgetc()`.
### Padding batching
Repeated spaces and zeroes are emitted through a small helper that writes
from static 16-byte buffers:
- spaces: `" "`
- zeroes: `"0000000000000000"`
Padding loops now output chunks rather than calling `stream_putc()` for each
byte.
## Testing
sim/nsh
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
