Skip to content

Commit

Permalink
fix:zstd normalize compress level
Browse files Browse the repository at this point in the history
  • Loading branch information
Max-Cheng committed Feb 12, 2024
1 parent 6b76eeb commit f27979a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions zstd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit f27979a

Please sign in to comment.