From ff0fe6ed8124c90e4a03884eb947989d06360518 Mon Sep 17 00:00:00 2001 From: Shivansh Vij Date: Thu, 12 Oct 2023 17:34:42 +0200 Subject: [PATCH] Fixing sizing issue Signed-off-by: Shivansh Vij --- buffer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buffer.go b/buffer.go index 22b43f8..4bf8ec4 100644 --- a/buffer.go +++ b/buffer.go @@ -33,9 +33,9 @@ func (buf *Buffer) Reset() { func (buf *Buffer) Grow(n int) { if cap(buf.b)-buf.offset < n { if cap(buf.b) < n { - buf.b = append(buf.b[:buf.offset], make([]byte, n)...) + buf.b = append(buf.b[:buf.offset], make([]byte, n+cap(buf.b)-buf.offset)...) } else { - buf.b = append(buf.b[:buf.offset], make([]byte, cap(buf.b))...) + buf.b = append(buf.b[:buf.offset], make([]byte, cap(buf.b)*2-buf.offset)...) } } }