Skip to content

Commit 1936861

Browse files
authored
Workaround weird regression with &[u8] and zopfli (#595)
Fixes #579. In lack of a proper understanding of what's going on here and why the issue is happening, this workaround will do for now.
1 parent f602e84 commit 1936861

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/deflate/zopfli_oxipng.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ pub fn deflate(data: &[u8], iterations: NonZeroU8) -> PngResult<Vec<u8>> {
88
iteration_count: iterations.into(),
99
..Default::default()
1010
};
11-
match zopfli::compress(options, zopfli::Format::Zlib, data, &mut output) {
11+
// Since Rust v1.74, passing &[u8] directly into zopfli causes a regression in compressed size
12+
// for some files. Wrapping the slice in another Read implementer such as Box fixes it for now.
13+
match zopfli::compress(options, zopfli::Format::Zlib, Box::new(data), &mut output) {
1214
Ok(_) => (),
1315
Err(_) => return Err(PngError::new("Failed to compress in zopfli")),
1416
};

0 commit comments

Comments
 (0)