summaryrefslogtreecommitdiff
path: root/vendor/github.com/klauspost/compress/zstd/encoder_options.go
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2021-04-12 09:45:08 +0000
committerGitHub <noreply@github.com>2021-04-12 09:45:08 +0000
commit3627c4b691a357fc531c2761f07ccfecf937dd12 (patch)
treeefb7643f74beadd946dc052f537743454a076462 /vendor/github.com/klauspost/compress/zstd/encoder_options.go
parent669311d8d8a8881571ccc81ce48b9202b15b9def (diff)
downloadpodman-3627c4b691a357fc531c2761f07ccfecf937dd12.tar.gz
podman-3627c4b691a357fc531c2761f07ccfecf937dd12.tar.bz2
podman-3627c4b691a357fc531c2761f07ccfecf937dd12.zip
Bump github.com/containers/image/v5 from 5.10.5 to 5.11.0
Bumps [github.com/containers/image/v5](https://github.com/containers/image) from 5.10.5 to 5.11.0. - [Release notes](https://github.com/containers/image/releases) - [Commits](https://github.com/containers/image/compare/v5.10.5...v5.11.0) Signed-off-by: dependabot[bot] <support@github.com>
Diffstat (limited to 'vendor/github.com/klauspost/compress/zstd/encoder_options.go')
-rw-r--r--vendor/github.com/klauspost/compress/zstd/encoder_options.go34
1 files changed, 28 insertions, 6 deletions
diff --git a/vendor/github.com/klauspost/compress/zstd/encoder_options.go b/vendor/github.com/klauspost/compress/zstd/encoder_options.go
index a7312f42a..18a47eb03 100644
--- a/vendor/github.com/klauspost/compress/zstd/encoder_options.go
+++ b/vendor/github.com/klauspost/compress/zstd/encoder_options.go
@@ -24,12 +24,12 @@ type encoderOptions struct {
allLitEntropy bool
customWindow bool
customALEntropy bool
+ lowMem bool
dict *dict
}
func (o *encoderOptions) setDefault() {
*o = encoderOptions{
- // use less ram: true for now, but may change.
concurrent: runtime.GOMAXPROCS(0),
crc: true,
single: nil,
@@ -37,20 +37,31 @@ func (o *encoderOptions) setDefault() {
windowSize: 8 << 20,
level: SpeedDefault,
allLitEntropy: true,
+ lowMem: false,
}
}
// encoder returns an encoder with the selected options.
func (o encoderOptions) encoder() encoder {
switch o.level {
+ case SpeedFastest:
+ if o.dict != nil {
+ return &fastEncoderDict{fastEncoder: fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), lowMem: o.lowMem}}}
+ }
+ return &fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), lowMem: o.lowMem}}
+
case SpeedDefault:
- return &doubleFastEncoder{fastEncoder: fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize)}}}
+ if o.dict != nil {
+ return &doubleFastEncoderDict{fastEncoderDict: fastEncoderDict{fastEncoder: fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), lowMem: o.lowMem}}}}
+ }
+ return &doubleFastEncoder{fastEncoder: fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), lowMem: o.lowMem}}}
case SpeedBetterCompression:
- return &betterFastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize)}}
+ if o.dict != nil {
+ return &betterFastEncoderDict{betterFastEncoder: betterFastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), lowMem: o.lowMem}}}
+ }
+ return &betterFastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), lowMem: o.lowMem}}
case SpeedBestCompression:
- return &bestFastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize)}}
- case SpeedFastest:
- return &fastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize)}}
+ return &bestFastEncoder{fastBase: fastBase{maxMatchOff: int32(o.windowSize), lowMem: o.lowMem}}
}
panic("unknown compression level")
}
@@ -276,6 +287,17 @@ func WithSingleSegment(b bool) EOption {
}
}
+// WithLowerEncoderMem will trade in some memory cases trade less memory usage for
+// slower encoding speed.
+// This will not change the window size which is the primary function for reducing
+// memory usage. See WithWindowSize.
+func WithLowerEncoderMem(b bool) EOption {
+ return func(o *encoderOptions) error {
+ o.lowMem = b
+ return nil
+ }
+}
+
// WithEncoderDict allows to register a dictionary that will be used for the encode.
// The encoder *may* choose to use no dictionary instead for certain payloads.
func WithEncoderDict(dict []byte) EOption {