Skip to content

Commit b7a0767

Browse files
committed
Workaround weird regression with &[u8] and zopfli
1 parent 290bf9d commit b7a0767

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)