]> git.kaiwu.me - haproxy.git/commitdiff
CLEANUP/MINOR: ncbmbuf: avoid noop memcpy when data ends on wrapping
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 19 Nov 2026 09:39:47 +0000 (10:39 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 19 Nov 2026 14:08:36 +0000 (15:08 +0100)
This patch is similar to the previous one applied to ncbuf. It changes
the comparison operator used against wrapping address during an add
operation, so that data fitting with the buffer end are inserted with a
single memcpy invocation.

src/ncbmbuf.c

index e642e3d215e0731ad3cfa1ab5af719439d7b5563..ed8a60888f6a69ebff58b57d12242e3f0d04ca3f 100644 (file)
@@ -274,7 +274,7 @@ enum ncb_ret ncbmb_add(struct ncbmbuf *buf, ncb_sz_t off,
 
        BUG_ON_HOT(off + len > buf->size);
 
-       if (ptr + len >= ncbmb_wrap(buf)) {
+       if (ptr + len > ncbmb_wrap(buf)) {
                ncb_sz_t sz1 = ncbmb_wrap(buf) - ptr;
 
                memcpy(ptr, data, sz1);