mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 09:42:22 +00:00
io: add Grow
to BinWriter
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
c69670c85b
commit
dacf025dd9
1 changed files with 9 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
package io
|
package io
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"io"
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
@ -144,3 +145,11 @@ func (w *BinWriter) WriteVarBytes(b []byte) {
|
||||||
func (w *BinWriter) WriteString(s string) {
|
func (w *BinWriter) WriteString(s string) {
|
||||||
w.WriteVarBytes([]byte(s))
|
w.WriteVarBytes([]byte(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Grow tries to increase underlying buffer capacity so that at least n bytes
|
||||||
|
// can be written without reallocation. If the writer is not a buffer, this is a no-op.
|
||||||
|
func (w *BinWriter) Grow(n int) {
|
||||||
|
if b, ok := w.w.(*bytes.Buffer); ok {
|
||||||
|
b.Grow(n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue