Browse code

pkg/pools: avoid copy of sync.Pool

Signed-off-by: Alexander Morozov <lk4d4@docker.com>

Alexander Morozov authored on 2016/06/24 08:09:13
Showing 1 changed files
... ...
@@ -28,7 +28,7 @@ const buffer32K = 32 * 1024
28 28
 
29 29
 // BufioReaderPool is a bufio reader that uses sync.Pool.
30 30
 type BufioReaderPool struct {
31
-	pool sync.Pool
31
+	pool *sync.Pool
32 32
 }
33 33
 
34 34
 func init() {
... ...
@@ -39,7 +39,7 @@ func init() {
39 39
 // newBufioReaderPoolWithSize is unexported because new pools should be
40 40
 // added here to be shared where required.
41 41
 func newBufioReaderPoolWithSize(size int) *BufioReaderPool {
42
-	pool := sync.Pool{
42
+	pool := &sync.Pool{
43 43
 		New: func() interface{} { return bufio.NewReaderSize(nil, size) },
44 44
 	}
45 45
 	return &BufioReaderPool{pool: pool}
... ...
@@ -80,13 +80,13 @@ func (bufPool *BufioReaderPool) NewReadCloserWrapper(buf *bufio.Reader, r io.Rea
80 80
 
81 81
 // BufioWriterPool is a bufio writer that uses sync.Pool.
82 82
 type BufioWriterPool struct {
83
-	pool sync.Pool
83
+	pool *sync.Pool
84 84
 }
85 85
 
86 86
 // newBufioWriterPoolWithSize is unexported because new pools should be
87 87
 // added here to be shared where required.
88 88
 func newBufioWriterPoolWithSize(size int) *BufioWriterPool {
89
-	pool := sync.Pool{
89
+	pool := &sync.Pool{
90 90
 		New: func() interface{} { return bufio.NewWriterSize(nil, size) },
91 91
 	}
92 92
 	return &BufioWriterPool{pool: pool}