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)
| 109 | // The default value is determined by the compression level and max 8MB. |
| 110 | // Cannot be changed with ResetWithOptions. |
| 111 | func 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. |
no outgoing calls
searching dependent graphs…