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

Function EncodeTo

zstd/simple_go124.go:20–34  ·  view source on GitHub ↗

EncodeTo appends the encoded data from src to dst.

(dst []byte, src []byte)

Source from the content-addressed store, hash-verified

18
19// EncodeTo appends the encoded data from src to dst.
20func EncodeTo(dst []byte, src []byte) []byte {
21 weakMu.Lock()
22 enc := simpleEnc.Value()
23 if enc == nil {
24 var err error
25 enc, err = NewWriter(nil, WithEncoderConcurrency(runtime.NumCPU()), WithWindowSize(1<<20), WithLowerEncoderMem(true), WithZeroFrames(true))
26 if err != nil {
27 panic("failed to create simple encoder: " + err.Error())
28 }
29 simpleEnc = weak.Make(enc)
30 }
31 weakMu.Unlock()
32
33 return enc.EncodeAll(src, dst)
34}
35
36// DecodeTo appends the decoded data from src to dst.
37// The maximum decoded size is 1GiB,

Callers 1

TestEncodeToFunction · 0.85

Calls 7

WithEncoderConcurrencyFunction · 0.85
WithWindowSizeFunction · 0.85
WithLowerEncoderMemFunction · 0.85
WithZeroFramesFunction · 0.85
EncodeAllMethod · 0.80
NewWriterFunction · 0.70
ErrorMethod · 0.45

Tested by 1

TestEncodeToFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…