Skip to content

Commit

Permalink
Adjust Level::Precise clamp range for flate2
Browse files Browse the repository at this point in the history
Previously, the clamp range was from "fastest" to "best" (1-9). This
commit changes the range to start from "none" (0) to allow for no
compression.
  • Loading branch information
eth3lbert committed Nov 23, 2024
1 parent e12ca46 commit 0b83b1a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ impl Level {
fn into_flate2(self) -> flate2::Compression {
let fastest = flate2::Compression::fast();
let best = flate2::Compression::best();
let none = flate2::Compression::none();

match self {
Self::Fastest => fastest,
Expand All @@ -224,7 +225,7 @@ impl Level {
quality
.try_into()
.unwrap_or(0)
.clamp(fastest.level(), best.level()),
.clamp(none.level(), best.level()),
),
Self::Default => flate2::Compression::default(),
}
Expand Down

0 comments on commit 0b83b1a

Please sign in to comment.