File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -254,8 +254,15 @@ impl Level {
254254 #[ cfg( feature = "zstd" ) ]
255255 fn into_zstd ( self ) -> i32 {
256256 let ( fastest, best) = libzstd:: compression_level_range ( ) . into_inner ( ) ;
257+
258+ // NOTE: zstd's "fastest" level is -131072 which can create outputs larger than inputs.
259+ // This library chooses a "fastest" level which has a more-or-less equivalent compression
260+ // ratio to gzip's fastest mode. We still allow precise levels to go negative.
261+ // See discussion in https://github.com/Nullus157/async-compression/issues/352
262+ const OUR_FASTEST : i32 = 1 ;
263+
257264 match self {
258- Self :: Fastest => fastest ,
265+ Self :: Fastest => OUR_FASTEST ,
259266 Self :: Best => best,
260267 Self :: Precise ( quality) => quality. clamp ( fastest, best) ,
261268 Self :: Default => libzstd:: DEFAULT_COMPRESSION_LEVEL ,
You can’t perform that action at this time.
0 commit comments