(p []byte)
| 204 | } |
| 205 | |
| 206 | func (zr *zstdReader) Read(p []byte) (n int, err error) { |
| 207 | if zr.zerr != nil { |
| 208 | return 0, zr.zerr |
| 209 | } |
| 210 | if zr.zr == nil { |
| 211 | reader, ok := zstdReaderPool.Get().(*zstd.Decoder) |
| 212 | if ok { |
| 213 | zr.zerr = reader.Reset(zr.body) |
| 214 | zr.zr = reader |
| 215 | } else { |
| 216 | zr.zr, zr.zerr = zstd.NewReader(zr.body, zstd.WithDecoderLowmem(true), zstd.WithDecoderMaxWindow(32<<20), zstd.WithDecoderConcurrency(1)) |
| 217 | } |
| 218 | if zr.zerr != nil { |
| 219 | return 0, zr.zerr |
| 220 | } |
| 221 | } |
| 222 | n, err = zr.zr.Read(p) |
| 223 | if err != nil { |
| 224 | // Usually this will be io.EOF, |
| 225 | // stash the decoder and keep the error. |
| 226 | zr.zr.Reset(nil) |
| 227 | zstdReaderPool.Put(zr.zr) |
| 228 | zr.zr = nil |
| 229 | zr.zerr = err |
| 230 | } |
| 231 | return |
| 232 | } |
| 233 | |
| 234 | func (zr *zstdReader) Close() error { |
| 235 | if zr.zr != nil { |
nothing calls this directly
no test coverage detected