Refactor: zopfli_buffer_size doesn't matter when not using Zopfli
This commit is contained in:
parent
ed922b060a
commit
543f469277
1 changed files with 11 additions and 4 deletions
15
src/write.rs
15
src/write.rs
|
@ -120,6 +120,7 @@ use crate::result::ZipError::InvalidArchive;
|
||||||
use crate::write::GenericZipWriter::{Closed, Storer};
|
use crate::write::GenericZipWriter::{Closed, Storer};
|
||||||
use crate::zipcrypto::ZipCryptoKeys;
|
use crate::zipcrypto::ZipCryptoKeys;
|
||||||
pub use zip_writer::ZipWriter;
|
pub use zip_writer::ZipWriter;
|
||||||
|
use crate::CompressionMethod::Deflated;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct ZipWriterStats {
|
struct ZipWriterStats {
|
||||||
|
@ -164,8 +165,13 @@ impl arbitrary::Arbitrary<'_> for FileOptions {
|
||||||
central_extra_data: Arc::new(vec![]),
|
central_extra_data: Arc::new(vec![]),
|
||||||
alignment: u16::arbitrary(u)?,
|
alignment: u16::arbitrary(u)?,
|
||||||
#[cfg(feature = "deflate-zopfli")]
|
#[cfg(feature = "deflate-zopfli")]
|
||||||
zopfli_buffer_size: Some(1 << u.int_in_range(10..=30)?),
|
zopfli_buffer_size: None,
|
||||||
};
|
};
|
||||||
|
#[cfg(feature = "deflate-zopfli")]
|
||||||
|
if options.compression_method == Deflated
|
||||||
|
&& options.compression_level > Compression::best().level() {
|
||||||
|
options.zopfli_buffer_size = Some(1 << u.int_in_range(10..=30)?);
|
||||||
|
}
|
||||||
u.arbitrary_loop(Some(0), Some((u16::MAX / 4) as u32), |u| {
|
u.arbitrary_loop(Some(0), Some((u16::MAX / 4) as u32), |u| {
|
||||||
options
|
options
|
||||||
.add_extra_data(
|
.add_extra_data(
|
||||||
|
@ -322,11 +328,12 @@ impl Default for FileOptions {
|
||||||
feature = "deflate-miniz",
|
feature = "deflate-miniz",
|
||||||
feature = "deflate-zlib"
|
feature = "deflate-zlib"
|
||||||
))]
|
))]
|
||||||
compression_method: CompressionMethod::Deflated,
|
compression_method: Deflated,
|
||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
feature = "deflate",
|
feature = "deflate",
|
||||||
feature = "deflate-miniz",
|
feature = "deflate-miniz",
|
||||||
feature = "deflate-zlib"
|
feature = "deflate-zlib",
|
||||||
|
feature = "deflate-zopfli"
|
||||||
)))]
|
)))]
|
||||||
compression_method: CompressionMethod::Stored,
|
compression_method: CompressionMethod::Stored,
|
||||||
compression_level: None,
|
compression_level: None,
|
||||||
|
@ -1148,7 +1155,7 @@ impl<W: Write + Seek> GenericZipWriter<W> {
|
||||||
feature = "deflate-zlib",
|
feature = "deflate-zlib",
|
||||||
feature = "deflate-zopfli"
|
feature = "deflate-zopfli"
|
||||||
))]
|
))]
|
||||||
CompressionMethod::Deflated => {
|
Deflated => {
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
not(feature = "deflate"),
|
not(feature = "deflate"),
|
||||||
not(feature = "deflate-miniz"),
|
not(feature = "deflate-miniz"),
|
||||||
|
|
Loading…
Add table
Reference in a new issue