Skip to content

Commit 593085b

Browse files
committed
Use pointer to avoid golint warning of copy lock
Signed-off-by: Lei Jitang <[email protected]>
1 parent 953699f commit 593085b

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

utils/pools.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const buffer32K = 32 * 1024
3535

3636
// BufioReaderPool is a bufio reader that uses sync.Pool.
3737
type BufioReaderPool struct {
38-
pool sync.Pool
38+
pool *sync.Pool
3939
}
4040

4141
func init() {
@@ -46,7 +46,7 @@ func init() {
4646
// newBufioReaderPoolWithSize is unexported because new pools should be
4747
// added here to be shared where required.
4848
func newBufioReaderPoolWithSize(size int) *BufioReaderPool {
49-
pool := sync.Pool{
49+
pool := &sync.Pool{
5050
New: func() interface{} { return bufio.NewReaderSize(nil, size) },
5151
}
5252
return &BufioReaderPool{pool: pool}
@@ -65,23 +65,15 @@ func (bufPool *BufioReaderPool) Put(b *bufio.Reader) {
6565
bufPool.pool.Put(b)
6666
}
6767

68-
// Copy is a convenience wrapper which uses a buffer to avoid allocation in io.Copy.
69-
func Copy(dst io.Writer, src io.Reader) (written int64, err error) {
70-
buf := BufioReader32KPool.Get(src)
71-
written, err = io.Copy(dst, buf)
72-
BufioReader32KPool.Put(buf)
73-
return
74-
}
75-
7668
// BufioWriterPool is a bufio writer that uses sync.Pool.
7769
type BufioWriterPool struct {
78-
pool sync.Pool
70+
pool *sync.Pool
7971
}
8072

8173
// newBufioWriterPoolWithSize is unexported because new pools should be
8274
// added here to be shared where required.
8375
func newBufioWriterPoolWithSize(size int) *BufioWriterPool {
84-
pool := sync.Pool{
76+
pool := &sync.Pool{
8577
New: func() interface{} { return bufio.NewWriterSize(nil, size) },
8678
}
8779
return &BufioWriterPool{pool: pool}

0 commit comments

Comments
 (0)