MCPcopy
hub / github.com/klauspost/compress / Read

Method Read

gzhttp/transport.go:206–232  ·  view source on GitHub ↗
(p []byte)

Source from the content-addressed store, hash-verified

204}
205
206func (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
234func (zr *zstdReader) Close() error {
235 if zr.zr != nil {

Callers

nothing calls this directly

Calls 6

NewReaderFunction · 0.92
WithDecoderLowmemFunction · 0.92
WithDecoderMaxWindowFunction · 0.92
WithDecoderConcurrencyFunction · 0.92
ResetMethod · 0.65
ReadMethod · 0.45

Tested by

no test coverage detected