From: Alex Rousskov Date: Fri, 7 Oct 2016 21:18:05 +0000 (-0600) Subject: Optimized/simplified buffering: Appending nothing is always possible. X-Git-Tag: SQUID_4_0_15~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1bd998545ba62008fae1d09e367678b960f443b9;p=thirdparty%2Fsquid.git 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. --- 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