From 2e39f1a1e35345938ca96043112573f298cedc10 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 20 Aug 2021 11:38:42 +0300 Subject: [PATCH] io: drop one allocation from NewBufBinWriter --- pkg/io/binaryBufWriter.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/io/binaryBufWriter.go b/pkg/io/binaryBufWriter.go index f90584fba..e64b58f2c 100644 --- a/pkg/io/binaryBufWriter.go +++ b/pkg/io/binaryBufWriter.go @@ -13,13 +13,14 @@ var ErrDrained = errors.New("buffer already drained") // writes via Bytes(). type BufBinWriter struct { *BinWriter - buf *bytes.Buffer + buf bytes.Buffer } // NewBufBinWriter makes a BufBinWriter with an empty byte buffer. func NewBufBinWriter() *BufBinWriter { - b := new(bytes.Buffer) - return &BufBinWriter{BinWriter: NewBinWriterFromIO(b), buf: b} + b := new(BufBinWriter) + b.BinWriter = NewBinWriterFromIO(&b.buf) + return b } // Len returns the number of bytes of the unread portion of the buffer.