This commit is contained in:
hmol233 2021-06-14 20:43:48 +08:00
parent b977899926
commit 3531b95d82
No known key found for this signature in database
GPG Key ID: D617A9DAB0C992D5

View File

@ -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,
}