Skip to content

Commit

Permalink
Reuse bufs slice instead of trowing away every time
Browse files Browse the repository at this point in the history
Just shrink it instead of discarding.

Signed-off-by: Frediano Ziglio <[email protected]>
  • Loading branch information
Frediano Ziglio committed Apr 27, 2022
1 parent a209843 commit 3a9213b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions buffer/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (b *Buffer) DumpTo(w io.Writer) (written int, err error) {
}
putBuf(b.toPool)

b.bufs = nil
b.bufs = b.bufs[:0]
b.Buf = nil
b.toPool = nil

Expand Down Expand Up @@ -214,7 +214,7 @@ func (b *Buffer) BuildBytes(reuse ...[]byte) []byte {
ret = append(ret, b.Buf...)
putBuf(b.toPool)

b.bufs = nil
b.bufs = b.bufs[:0]
b.toPool = nil
b.Buf = nil

Expand Down

0 comments on commit 3a9213b

Please sign in to comment.