GetZlibReader returns a ZLibReader that is managed by a sync.Pool. Returns a ZLibReader that is reset using a dictionary that is also managed by a sync.Pool. After use, the ZLibReader should be put back into the sync.Pool by calling PutZlibReader.
(r io.Reader)
| 41 | // After use, the ZLibReader should be put back into the sync.Pool |
| 42 | // by calling PutZlibReader. |
| 43 | func GetZlibReader(r io.Reader) (ZLibReader, error) { |
| 44 | z := zlibReader.Get().(ZLibReader) |
| 45 | z.dict = GetByteSlice() |
| 46 | |
| 47 | err := z.Reader.Reset(r, *z.dict) |
| 48 | |
| 49 | return z, err |
| 50 | } |
| 51 | |
| 52 | // PutZlibReader puts z back into its sync.Pool, first closing the reader. |
| 53 | // The Byte slice dictionary is also put back into its sync.Pool. |
searching dependent graphs…