@@ -19,30 +19,26 @@ import (
1919
2020var (
2121 // BufioReader32KPool is a pool which returns bufio.Reader with a 32K buffer.
22- BufioReader32KPool * BufioReaderPool
22+ BufioReader32KPool = newBufioReaderPoolWithSize ( buffer32K )
2323 // BufioWriter32KPool is a pool which returns bufio.Writer with a 32K buffer.
24- BufioWriter32KPool * BufioWriterPool
24+ BufioWriter32KPool = newBufioWriterPoolWithSize ( buffer32K )
2525)
2626
2727const buffer32K = 32 * 1024
2828
2929// BufioReaderPool is a bufio reader that uses sync.Pool.
3030type BufioReaderPool struct {
31- pool * sync.Pool
32- }
33-
34- func init () {
35- BufioReader32KPool = newBufioReaderPoolWithSize (buffer32K )
36- BufioWriter32KPool = newBufioWriterPoolWithSize (buffer32K )
31+ pool sync.Pool
3732}
3833
3934// newBufioReaderPoolWithSize is unexported because new pools should be
4035// added here to be shared where required.
4136func newBufioReaderPoolWithSize (size int ) * BufioReaderPool {
42- pool := & sync.Pool {
43- New : func () interface {} { return bufio .NewReaderSize (nil , size ) },
37+ return & BufioReaderPool {
38+ pool : sync.Pool {
39+ New : func () interface {} { return bufio .NewReaderSize (nil , size ) },
40+ },
4441 }
45- return & BufioReaderPool {pool : pool }
4642}
4743
4844// Get returns a bufio.Reader which reads from r. The buffer size is that of the pool.
@@ -80,16 +76,17 @@ func (bufPool *BufioReaderPool) NewReadCloserWrapper(buf *bufio.Reader, r io.Rea
8076
8177// BufioWriterPool is a bufio writer that uses sync.Pool.
8278type BufioWriterPool struct {
83- pool * sync.Pool
79+ pool sync.Pool
8480}
8581
8682// newBufioWriterPoolWithSize is unexported because new pools should be
8783// added here to be shared where required.
8884func newBufioWriterPoolWithSize (size int ) * BufioWriterPool {
89- pool := & sync.Pool {
90- New : func () interface {} { return bufio .NewWriterSize (nil , size ) },
85+ return & BufioWriterPool {
86+ pool : sync.Pool {
87+ New : func () interface {} { return bufio .NewWriterSize (nil , size ) },
88+ },
9189 }
92- return & BufioWriterPool {pool : pool }
9390}
9491
9592// Get returns a bufio.Writer which writes to w. The buffer size is that of the pool.
0 commit comments