forked from TrueCloudLab/neoneo-go
io: drop one allocation from NewBufBinWriter
This commit is contained in:
parent
a68a8aa8fc
commit
2e39f1a1e3
1 changed files with 4 additions and 3 deletions
|
@ -13,13 +13,14 @@ var ErrDrained = errors.New("buffer already drained")
|
||||||
// writes via Bytes().
|
// writes via Bytes().
|
||||||
type BufBinWriter struct {
|
type BufBinWriter struct {
|
||||||
*BinWriter
|
*BinWriter
|
||||||
buf *bytes.Buffer
|
buf bytes.Buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewBufBinWriter makes a BufBinWriter with an empty byte buffer.
|
// NewBufBinWriter makes a BufBinWriter with an empty byte buffer.
|
||||||
func NewBufBinWriter() *BufBinWriter {
|
func NewBufBinWriter() *BufBinWriter {
|
||||||
b := new(bytes.Buffer)
|
b := new(BufBinWriter)
|
||||||
return &BufBinWriter{BinWriter: NewBinWriterFromIO(b), buf: b}
|
b.BinWriter = NewBinWriterFromIO(&b.buf)
|
||||||
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
// Len returns the number of bytes of the unread portion of the buffer.
|
// Len returns the number of bytes of the unread portion of the buffer.
|
||||||
|
|
Loading…
Reference in a new issue