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 bf51dd8958a20f7b67bdd373507aba4e7731dad8 Author: chao an <[email protected]> AuthorDate: Mon Oct 26 14:17:39 2026 +0800 drivers/note: Copy RAM note records in chunks Replace the byte-at-a-time copy from the RAM note circular buffer to the caller buffer with memcpy() over the current contiguous ring segment. The read side still consumes NOTE_ALIGN() bytes from the ring, but the payload copy now advances the destination pointer and read index by the chunk length. This also makes the read path match the existing bulk-copy write path. This reduces loop overhead when larger RAM note records are drained. Signed-off-by: chao an <[email protected]> --- drivers/note/noteram_driver.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/note/noteram_driver.c b/drivers/note/noteram_driver.c index 7c8a74f654b..d0f8995fe4f 100644 --- a/drivers/note/noteram_driver.c +++ b/drivers/note/noteram_driver.c @@ -409,19 +409,27 @@ static ssize_t noteram_get(FAR struct noteram_driver_s *drv, return -EFBIG; } - /* Loop until the note has been transferred to the user buffer */ + /* Copy the note to the user buffer, splitting at the circular buffer + * boundary if necessary. + */ remaining = (unsigned int)notelen; while (remaining > 0) { - /* Copy the next byte at the read index */ + unsigned int ncopy = drv->ni_bufsize - read; + + if (ncopy > remaining) + { + ncopy = remaining; + } - *buffer++ = drv->ni_buffer[read]; + memcpy(buffer, &drv->ni_buffer[read], ncopy); /* Adjust indices and counts */ - read = noteram_next(drv, read, 1); - remaining--; + buffer += ncopy; + read = noteram_next(drv, read, ncopy); + remaining -= ncopy; } drv->ni_read = noteram_next(drv, drv->ni_read, NOTE_ALIGN(notelen));
