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

Method encoder

zstd/encoder_options.go:51–73  ·  view source on GitHub ↗

encoder returns an encoder with the selected options.

()

Source from the content-addressed store, hash-verified

49
50// encoder returns an encoder with the selected options.
51func (o encoderOptions) encoder() encoder {
52 switch o.level {
53 case SpeedFastest:
54 if o.dict != nil {
55 return &fastEncoderDict{fastEncoder: fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), bufferReset: math.MaxInt32 - int32(o.windowSize*2), lowMem: o.lowMem}}}
56 }
57 return &fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), bufferReset: math.MaxInt32 - int32(o.windowSize*2), lowMem: o.lowMem}}
58
59 case SpeedDefault:
60 if o.dict != nil {
61 return &doubleFastEncoderDict{fastEncoderDict: fastEncoderDict{fastEncoder: fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), bufferReset: math.MaxInt32 - int32(o.windowSize*2), lowMem: o.lowMem}}}}
62 }
63 return &doubleFastEncoder{fastEncoder: fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), bufferReset: math.MaxInt32 - int32(o.windowSize*2), lowMem: o.lowMem}}}
64 case SpeedBetterCompression:
65 if o.dict != nil {
66 return &betterFastEncoderDict{betterFastEncoder: betterFastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), bufferReset: math.MaxInt32 - int32(o.windowSize*2), lowMem: o.lowMem}}}
67 }
68 return &betterFastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), bufferReset: math.MaxInt32 - int32(o.windowSize*2), lowMem: o.lowMem}}
69 case SpeedBestCompression:
70 return &bestFastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), bufferReset: math.MaxInt32 - int32(o.windowSize*2), lowMem: o.lowMem}}
71 }
72 panic("unknown compression level")
73}
74
75// WithEncoderCRC will add CRC value to output.
76// Output will be 4 bytes larger.

Callers 3

BuildDictFunction · 0.95
initializeMethod · 0.80
ResetMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected