]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Optimized/simplified buffering: Appending nothing is always possible.
authorAlex Rousskov <rousskov@measurement-factory.com>
Sun, 9 Oct 2016 15:55:58 +0000 (04:55 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 9 Oct 2016 15:55:58 +0000 (04:55 +1300)
This change avoids CoW when appending an empty buffer to MemBlob or
SBuf, making "if !empty then append()" caller complications unnecessary.

src/MemBlob.h

index de7133224b486db20c1ffdb4f9aa2a22fc4aaac6..fed056fc172cdb04005557917e0ba415eb0608e7 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