From 49c1e1307a90411e3cad8b294ec662cf6bd4aba9 Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Mon, 10 Oct 2016 04:55:58 +1300 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/MemBlob.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MemBlob.h b/src/MemBlob.h index de7133224b..fed056fc17 100644 --- a/src/MemBlob.h +++ b/src/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.2