From: Amaury Denoyelle Date: Thu, 19 Nov 2026 09:39:47 +0000 (+0100) Subject: CLEANUP/MINOR: ncbmbuf: avoid noop memcpy when data ends on wrapping X-Git-Url: https://git.kaiwu.me/web/%22data:,/doc/static/gitweb.js?a=commitdiff_plain;h=102fad424f3fa7e898f7f0ca99afe46fe052a2c2;p=haproxy.git CLEANUP/MINOR: ncbmbuf: avoid noop memcpy when data ends on wrapping 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. --- diff --git a/src/ncbmbuf.c b/src/ncbmbuf.c index e642e3d21..ed8a60888 100644 --- a/src/ncbmbuf.c +++ b/src/ncbmbuf.c @@ -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);