Skip to content

Commit 26ba9bd

Browse files
committed
Workaround weird regression with &[u8] and zopfli
1 parent 4cb8296 commit 26ba9bd

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

0 commit comments

Comments
 (0)