1
0
hmol233 4 жил өмнө
parent
commit
3531b95d82

+ 7 - 0
common/buf/buffer.go

@@ -26,6 +26,13 @@ type Buffer struct {
 
 
 // New creates a Buffer with 0 length and 2K capacity.
 // New creates a Buffer with 0 length and 2K capacity.
 func New() *Buffer {
 func New() *Buffer {
+	buf := pool.Get().([]byte)
+	if cap(buf) >= Size {
+		buf = buf[:Size]
+	} else {
+		buf = make([]byte, Size)
+	}
+
 	return &Buffer{
 	return &Buffer{
 		v: buf,
 		v: buf,
 	}
 	}