From 871ed4abd4f9f9af9b5ac4dacdafa3588a2098a8 Mon Sep 17 00:00:00 2001 From: Max-Cheng Date: Wed, 31 Jan 2024 22:01:16 +0800 Subject: [PATCH] fix:zstd normalize compress level --- zstd.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zstd.go b/zstd.go index df021706a4..4218db4595 100644 --- a/zstd.go +++ b/zstd.go @@ -108,6 +108,7 @@ func AppendZstdBytesLevel(dst, src []byte, level int) []byte { } func WriteZstdLevel(w io.Writer, p []byte, level int) (int, error) { + level = normalizeZstdCompressLevel(level) switch w.(type) { case *byteSliceWriter, *bytes.Buffer, @@ -178,8 +179,6 @@ func AppendUnzstdBytes(dst, src []byte) ([]byte, error) { // normalizes compression level into [0..7], so it could be used as an index // in *PoolMap. func normalizeZstdCompressLevel(level int) int { - // -2 is the lowest compression level - CompressHuffmanOnly - // 9 is the highest compression level - CompressBestCompression if level < CompressZstdSpeedNotSet || level > CompressZstdBestCompression { level = CompressZstdDefault }