From 3531b95d829978f99ef4a53af27f433076868261 Mon Sep 17 00:00:00 2001 From: hmol233 <82594500+hmol233@users.noreply.github.com> Date: Mon, 14 Jun 2021 20:43:48 +0800 Subject: [PATCH] ? --- common/buf/buffer.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/buf/buffer.go b/common/buf/buffer.go index 7c8f965d..baca8238 100644 --- a/common/buf/buffer.go +++ b/common/buf/buffer.go @@ -26,6 +26,13 @@ type Buffer struct { // New creates a Buffer with 0 length and 2K capacity. func New() *Buffer { + buf := pool.Get().([]byte) + if cap(buf) >= Size { + buf = buf[:Size] + } else { + buf = make([]byte, Size) + } + return &Buffer{ v: buf, }