pkg/pools: avoid copy of sync.Pool
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
53ce0aa26a
commit
e74a7f42a9
1 changed files with 4 additions and 4 deletions
|
@ -28,7 +28,7 @@ const buffer32K = 32 * 1024
|
||||||
|
|
||||||
// BufioReaderPool is a bufio reader that uses sync.Pool.
|
// BufioReaderPool is a bufio reader that uses sync.Pool.
|
||||||
type BufioReaderPool struct {
|
type BufioReaderPool struct {
|
||||||
pool sync.Pool
|
pool *sync.Pool
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -39,7 +39,7 @@ func init() {
|
||||||
// newBufioReaderPoolWithSize is unexported because new pools should be
|
// newBufioReaderPoolWithSize is unexported because new pools should be
|
||||||
// added here to be shared where required.
|
// added here to be shared where required.
|
||||||
func newBufioReaderPoolWithSize(size int) *BufioReaderPool {
|
func newBufioReaderPoolWithSize(size int) *BufioReaderPool {
|
||||||
pool := sync.Pool{
|
pool := &sync.Pool{
|
||||||
New: func() interface{} { return bufio.NewReaderSize(nil, size) },
|
New: func() interface{} { return bufio.NewReaderSize(nil, size) },
|
||||||
}
|
}
|
||||||
return &BufioReaderPool{pool: pool}
|
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.
|
// BufioWriterPool is a bufio writer that uses sync.Pool.
|
||||||
type BufioWriterPool struct {
|
type BufioWriterPool struct {
|
||||||
pool sync.Pool
|
pool *sync.Pool
|
||||||
}
|
}
|
||||||
|
|
||||||
// newBufioWriterPoolWithSize is unexported because new pools should be
|
// newBufioWriterPoolWithSize is unexported because new pools should be
|
||||||
// added here to be shared where required.
|
// added here to be shared where required.
|
||||||
func newBufioWriterPoolWithSize(size int) *BufioWriterPool {
|
func newBufioWriterPoolWithSize(size int) *BufioWriterPool {
|
||||||
pool := sync.Pool{
|
pool := &sync.Pool{
|
||||||
New: func() interface{} { return bufio.NewWriterSize(nil, size) },
|
New: func() interface{} { return bufio.NewWriterSize(nil, size) },
|
||||||
}
|
}
|
||||||
return &BufioWriterPool{pool: pool}
|
return &BufioWriterPool{pool: pool}
|
||||||
|
|
Loading…
Reference in a new issue