From e74a7f42a9aee92103018641bf09a92e43ca9200 Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Thu, 23 Jun 2016 16:09:13 -0700 Subject: [PATCH] pkg/pools: avoid copy of sync.Pool Signed-off-by: Alexander Morozov --- pools/pools.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pools/pools.go b/pools/pools.go index 76e84f9..6f5988e 100644 --- a/pools/pools.go +++ b/pools/pools.go @@ -28,7 +28,7 @@ const buffer32K = 32 * 1024 // BufioReaderPool is a bufio reader that uses sync.Pool. type BufioReaderPool struct { - pool sync.Pool + pool *sync.Pool } func init() { @@ -39,7 +39,7 @@ func init() { // newBufioReaderPoolWithSize is unexported because new pools should be // added here to be shared where required. func newBufioReaderPoolWithSize(size int) *BufioReaderPool { - pool := sync.Pool{ + pool := &sync.Pool{ New: func() interface{} { return bufio.NewReaderSize(nil, size) }, } return &BufioReaderPool{pool: pool} @@ -80,13 +80,13 @@ func (bufPool *BufioReaderPool) NewReadCloserWrapper(buf *bufio.Reader, r io.Rea // BufioWriterPool is a bufio writer that uses sync.Pool. type BufioWriterPool struct { - pool sync.Pool + pool *sync.Pool } // newBufioWriterPoolWithSize is unexported because new pools should be // added here to be shared where required. func newBufioWriterPoolWithSize(size int) *BufioWriterPool { - pool := sync.Pool{ + pool := &sync.Pool{ New: func() interface{} { return bufio.NewWriterSize(nil, size) }, } return &BufioWriterPool{pool: pool}