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

Method writeJobs

zstd/encoder.go:214–247  ·  view source on GitHub ↗
(p []byte)

Source from the content-addressed store, hash-verified

212}
213
214func (e *Encoder) writeJobs(p []byte) (n int, err error) {
215 s := &e.state
216 js := &s.jobs
217 jobSize := js.jobSize
218 if cap(js.filling) == 0 && len(p) > 0 {
219 js.filling = make([]byte, 0, jobSize)
220 }
221 for len(p) > 0 {
222 if len(p)+len(js.filling) < jobSize {
223 if e.o.crc {
224 _, _ = s.encoder.CRC().Write(p)
225 }
226 js.filling = append(js.filling, p...)
227 return n + len(p), nil
228 }
229 add := p
230 if len(p)+len(js.filling) > jobSize {
231 add = add[:jobSize-len(js.filling)]
232 }
233 if e.o.crc {
234 _, _ = s.encoder.CRC().Write(add)
235 }
236 js.filling = append(js.filling, add...)
237 p = p[len(add):]
238 n += len(add)
239 if len(js.filling) < jobSize {
240 return n, nil
241 }
242 if err := e.dispatchJob(false); err != nil {
243 return n, err
244 }
245 }
246 return n, nil
247}
248
249func (e *Encoder) writeBlocks(p []byte) (n int, err error) {
250 s := &e.state

Callers 1

WriteMethod · 0.95

Calls 3

dispatchJobMethod · 0.95
WriteMethod · 0.65
CRCMethod · 0.65

Tested by

no test coverage detected