Add warning for level > 3 for non-zlib
It's not obvious immediately that these levels don't have any effect on libdeflater and Zopfli, since they don't iterate over zlib-specific fine-tuned options. Hence, show warning so that user knows they're getting "downgraded" to level 3.
This commit is contained in:
parent
8e13c3e0d7
commit
cffc3ce991
1 changed files with 16 additions and 8 deletions
24
src/main.rs
24
src/main.rs
|
|
@ -321,16 +321,13 @@ fn parse_opts_into_struct(
|
||||||
.init()
|
.init()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let mut opts = if let Some(x) = matches.value_of("optimization") {
|
let level = match matches.value_of("optimization") {
|
||||||
if let Ok(opt) = x.parse::<u8>() {
|
Some(x) => x.parse::<u8>().unwrap(),
|
||||||
Options::from_preset(opt)
|
None => 2,
|
||||||
} else {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Options::default()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut opts = Options::from_preset(level);
|
||||||
|
|
||||||
if let Some(x) = matches.value_of("interlace") {
|
if let Some(x) = matches.value_of("interlace") {
|
||||||
opts.interlace = x.parse::<u8>().ok();
|
opts.interlace = x.parse::<u8>().ok();
|
||||||
}
|
}
|
||||||
|
|
@ -494,6 +491,17 @@ fn parse_opts_into_struct(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if level > 3 {
|
||||||
|
match opts.deflate {
|
||||||
|
Deflaters::Zlib { .. } => {}
|
||||||
|
_ => {
|
||||||
|
warn!(
|
||||||
|
"Level 4 and above are equivalent to level 3 for compressors other than zlib"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(x) = matches.value_of("threads") {
|
if let Some(x) = matches.value_of("threads") {
|
||||||
let threads = x.parse::<usize>().unwrap();
|
let threads = x.parse::<usize>().unwrap();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue