Browse code

Remove pools_nopool.go & build tag from pools.go

Fix #11576

Signed-off-by: Gleb Shepelev <shepelyov.g@gmail.com>

WiseTrem authored on 2015/04/10 05:26:36
Showing 2 changed files
... ...
@@ -1,5 +1,3 @@
1
-// +build go1.3
2
-
3 1
 // Package pools provides a collection of pools which provide various
4 2
 // data types with buffers. These can be used to lower the number of
5 3
 // memory allocations and reuse buffers.
6 4
deleted file mode 100644
... ...
@@ -1,73 +0,0 @@
1
-// +build !go1.3
2
-
3
-package pools
4
-
5
-import (
6
-	"bufio"
7
-	"io"
8
-
9
-	"github.com/docker/docker/pkg/ioutils"
10
-)
11
-
12
-var (
13
-	BufioReader32KPool *BufioReaderPool
14
-	BufioWriter32KPool *BufioWriterPool
15
-)
16
-
17
-const buffer32K = 32 * 1024
18
-
19
-type BufioReaderPool struct {
20
-	size int
21
-}
22
-
23
-func init() {
24
-	BufioReader32KPool = newBufioReaderPoolWithSize(buffer32K)
25
-	BufioWriter32KPool = newBufioWriterPoolWithSize(buffer32K)
26
-}
27
-
28
-func newBufioReaderPoolWithSize(size int) *BufioReaderPool {
29
-	return &BufioReaderPool{size: size}
30
-}
31
-
32
-func (bufPool *BufioReaderPool) Get(r io.Reader) *bufio.Reader {
33
-	return bufio.NewReaderSize(r, bufPool.size)
34
-}
35
-
36
-func (bufPool *BufioReaderPool) Put(b *bufio.Reader) {
37
-	b.Reset(nil)
38
-}
39
-
40
-func (bufPool *BufioReaderPool) NewReadCloserWrapper(buf *bufio.Reader, r io.Reader) io.ReadCloser {
41
-	return ioutils.NewReadCloserWrapper(r, func() error {
42
-		if readCloser, ok := r.(io.ReadCloser); ok {
43
-			return readCloser.Close()
44
-		}
45
-		return nil
46
-	})
47
-}
48
-
49
-type BufioWriterPool struct {
50
-	size int
51
-}
52
-
53
-func newBufioWriterPoolWithSize(size int) *BufioWriterPool {
54
-	return &BufioWriterPool{size: size}
55
-}
56
-
57
-func (bufPool *BufioWriterPool) Get(w io.Writer) *bufio.Writer {
58
-	return bufio.NewWriterSize(w, bufPool.size)
59
-}
60
-
61
-func (bufPool *BufioWriterPool) Put(b *bufio.Writer) {
62
-	b.Reset(nil)
63
-}
64
-
65
-func (bufPool *BufioWriterPool) NewWriteCloserWrapper(buf *bufio.Writer, w io.Writer) io.WriteCloser {
66
-	return ioutils.NewWriteCloserWrapper(w, func() error {
67
-		buf.Flush()
68
-		if writeCloser, ok := w.(io.WriteCloser); ok {
69
-			return writeCloser.Close()
70
-		}
71
-		return nil
72
-	})
73
-}