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

Function WithWindowSize

zstd/encoder_options.go:111–133  ·  view source on GitHub ↗

WithWindowSize will set the maximum allowed back-reference distance. The value must be a power of two between MinWindowSize and MaxWindowSize. A larger value will enable better compression but allocate more memory and, for above-default values, take considerably longer. The default value is determin

(n int)

Source from the content-addressed store, hash-verified

109// The default value is determined by the compression level and max 8MB.
110// Cannot be changed with ResetWithOptions.
111func WithWindowSize(n int) EOption {
112 return func(o *encoderOptions) error {
113 switch {
114 case n < MinWindowSize:
115 return fmt.Errorf("window size must be at least %d", MinWindowSize)
116 case n > MaxWindowSize:
117 return fmt.Errorf("window size must be at most %d", MaxWindowSize)
118 case (n & (n - 1)) != 0:
119 return errors.New("window size must be a power of 2")
120 }
121 if o.resetOpt && n != o.windowSize {
122 return errors.New("WithWindowSize cannot be changed on Reset")
123 }
124
125 o.windowSize = n
126 o.customWindow = true
127 if o.blockSize > o.windowSize {
128 o.blockSize = o.windowSize
129 o.customBlockSize = true
130 }
131 return nil
132 }
133}
134
135// WithEncoderPadding will add padding to all output so the size will be a multiple of n.
136// This can be used to obfuscate the exact output size or make blocks of a certain size.

Callers 15

ExampleZipCompressorFunction · 0.92
BenchmarkTransportFunction · 0.92
addLevelPoolFunction · 0.92
FuzzEncodingFunction · 0.85
TestEncoder_SmallDictFunction · 0.85
EncodeToFunction · 0.85
getConcBlockOptsFunction · 0.85

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…