aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/klauspost/compress/zstd/decoder_options.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2022-09-30 06:45:24 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2022-09-30 06:45:24 -0400
commitfe3c91d581ed8044fdd0cf07542965b5daed255b (patch)
tree2ecc9d29cb45c708885fd06217d308df2bf81221 /vendor/github.com/klauspost/compress/zstd/decoder_options.go
parentd88acd83a1bdd260fc69e0ff115ff99d55bb7760 (diff)
downloadpodman-fe3c91d581ed8044fdd0cf07542965b5daed255b.tar.gz
podman-fe3c91d581ed8044fdd0cf07542965b5daed255b.tar.bz2
podman-fe3c91d581ed8044fdd0cf07542965b5daed255b.zip
Update vendor containers/(common,image)
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/github.com/klauspost/compress/zstd/decoder_options.go')
-rw-r--r--vendor/github.com/klauspost/compress/zstd/decoder_options.go34
1 files changed, 24 insertions, 10 deletions
diff --git a/vendor/github.com/klauspost/compress/zstd/decoder_options.go b/vendor/github.com/klauspost/compress/zstd/decoder_options.go
index 666c2715f..f42448e69 100644
--- a/vendor/github.com/klauspost/compress/zstd/decoder_options.go
+++ b/vendor/github.com/klauspost/compress/zstd/decoder_options.go
@@ -14,21 +14,23 @@ type DOption func(*decoderOptions) error
// options retains accumulated state of multiple options.
type decoderOptions struct {
- lowMem bool
- concurrent int
- maxDecodedSize uint64
- maxWindowSize uint64
- dicts []dict
- ignoreChecksum bool
- limitToCap bool
+ lowMem bool
+ concurrent int
+ maxDecodedSize uint64
+ maxWindowSize uint64
+ dicts []dict
+ ignoreChecksum bool
+ limitToCap bool
+ decodeBufsBelow int
}
func (o *decoderOptions) setDefault() {
*o = decoderOptions{
// use less ram: true for now, but may change.
- lowMem: true,
- concurrent: runtime.GOMAXPROCS(0),
- maxWindowSize: MaxWindowSize,
+ lowMem: true,
+ concurrent: runtime.GOMAXPROCS(0),
+ maxWindowSize: MaxWindowSize,
+ decodeBufsBelow: 128 << 10,
}
if o.concurrent > 4 {
o.concurrent = 4
@@ -126,6 +128,18 @@ func WithDecodeAllCapLimit(b bool) DOption {
}
}
+// WithDecodeBuffersBelow will fully decode readers that have a
+// `Bytes() []byte` and `Len() int` interface similar to bytes.Buffer.
+// This typically uses less allocations but will have the full decompressed object in memory.
+// Note that DecodeAllCapLimit will disable this, as well as giving a size of 0 or less.
+// Default is 128KiB.
+func WithDecodeBuffersBelow(size int) DOption {
+ return func(o *decoderOptions) error {
+ o.decodeBufsBelow = size
+ return nil
+ }
+}
+
// IgnoreChecksum allows to forcibly ignore checksum checking.
func IgnoreChecksum(b bool) DOption {
return func(o *decoderOptions) error {