From 1bd998545ba62008fae1d09e367678b960f443b9 Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Fri, 7 Oct 2016 15:18:05 -0600 Subject: [PATCH] Optimized/simplified buffering: Appending nothing is always possible. This change avoids CoW when appending an empty buffer to MemBlob or SBuf, making "if !empty then append()" caller complications unnecessary. --- src/sbuf/MemBlob.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sbuf/MemBlob.h b/src/sbuf/MemBlob.h index a2b670fd76..8d727a6579 100644 --- a/src/sbuf/MemBlob.h +++ b/src/sbuf/MemBlob.h @@ -72,7 +72,7 @@ public: */ bool canAppend(const size_type off, const size_type n) const { // TODO: ignore offset (and adjust size) when the blob is not shared? - return isAppendOffset(off) && willFit(n); + return (isAppendOffset(off) && willFit(n)) || !n; } /** adjusts internal object state as if exactly n bytes were append()ed -- 2.47.3