MCPcopy Index your code
hub / github.com/klauspost/compress / Read

Method Read

zstd/decoder.go:123–159  ·  view source on GitHub ↗

Read bytes from the decompressed stream into p. Returns the number of bytes read and any error that occurred. When the stream is done, io.EOF will be returned.

(p []byte)

Source from the content-addressed store, hash-verified

121// Returns the number of bytes read and any error that occurred.
122// When the stream is done, io.EOF will be returned.
123func (d *Decoder) Read(p []byte) (int, error) {
124 var n int
125 for {
126 if len(d.current.b) > 0 {
127 filled := copy(p, d.current.b)
128 p = p[filled:]
129 d.current.b = d.current.b[filled:]
130 n += filled
131 }
132 if len(p) == 0 {
133 break
134 }
135 if len(d.current.b) == 0 {
136 // We have an error and no more data
137 if d.current.err != nil {
138 break
139 }
140 if !d.nextBlock(n == 0) {
141 return n, d.current.err
142 }
143 }
144 }
145 if len(d.current.b) > 0 {
146 if debugDecoder {
147 println("returning", n, "still bytes left:", len(d.current.b))
148 }
149 // Only return error at end of block
150 return n, nil
151 }
152 if d.current.err != nil {
153 d.drainOutput()
154 }
155 if debugDecoder {
156 println("returning", n, d.current.err, len(d.decoders))
157 }
158 return n, d.current.err
159}
160
161// Reset will reset the decoder the supplied stream after the current has finished processing.
162// Note that this functionality cannot be used after Close has been called.

Callers 10

ReadMethod · 0.45
ReadFromMethod · 0.45
readFromJobsMethod · 0.45
mustReadFromMethod · 0.45

Calls 3

nextBlockMethod · 0.95
drainOutputMethod · 0.95
printlnFunction · 0.85