]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Optimized/simplified buffering: Appending nothing is always possible.
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 7 Oct 2016 21:18:05 +0000 (15:18 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Fri, 7 Oct 2016 21:18:05 +0000 (15:18 -0600)
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

index a2b670fd76b888b82322665d79456d47a0a4c656..8d727a6579d37301a60f406b9b73256a713b445a 100644 (file)
@@ -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