Skip to content

Commit 46db403

Browse files
committed
upgrade to libz-sys 1.1.23, using libz-ng 2.2.4
This release makes some changes to the medium algorithm, see zlib-ng/zlib-ng#1938
1 parent 3945f49 commit 46db403

File tree

7 files changed

+17
-14
lines changed

7 files changed

+17
-14
lines changed

.github/workflows/checks.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
# wasm32-wasip1 (std for wasip2 is unstable)
3232
WASI_SDK_PATH: /tmp/wasi-sdk-24.0-x86_64-linux
3333
CC_wasm32_wasip1: /tmp/wasi-sdk-24.0-x86_64-linux/bin/clang
34+
CXX_wasm32_wasip1: /tmp/wasi-sdk-24.0-x86_64-linux/bin/clang++
3435
AR_wasm32_wasip1: /tmp/wasi-sdk-24.0-x86_64-linux/bin/llvm-ar
3536
CARGO_TARGET_WASM32_WASIP1_RUNNER: "wasmtime --dir /home/runner/work/zlib-rs/zlib-rs/test-libz-rs-sys --dir /tmp/"
3637
CARGO_TARGET_WASM32_WASIP1_RUSTFLAGS: "-Ctarget-feature=+simd128"
@@ -60,12 +61,12 @@ jobs:
6061
- target: "i686-unknown-linux-gnu"
6162
os: ubuntu-latest
6263
codecov: true
63-
packages: gcc-i686-linux-gnu
64+
packages: gcc-i686-linux-gnu g++-i686-linux-gnu
6465

6566
- target: "s390x-unknown-linux-gnu"
6667
os: ubuntu-latest
6768
codecov: false
68-
packages: gcc-s390x-linux-gnu qemu-user qemu-user-static
69+
packages: gcc-s390x-linux-gnu g++-s390x-linux-gnu qemu-user qemu-user-static
6970

7071
- target: "wasm32-wasip1"
7172
os: ubuntu-latest
@@ -470,7 +471,7 @@ jobs:
470471
- name: Install gcc
471472
if: ${{ contains(matrix.target, 'windows') }}
472473
run: |
473-
sudo apt-get install gcc-mingw-w64-x86-64
474+
sudo apt-get install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64
474475
x86_64-w64-mingw32-gcc --help
475476
- name: Install cargo-nextest
476477
uses: taiki-e/install-action@d12e869b89167df346dd0ff65da342d1fb1202fb # v2.53.2

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ opt-level = 1 # required for the tail calls in inflate to optimize
3333

3434
[workspace.dependencies]
3535
libloading = "0.8.1"
36-
# FIXME: later libz-sys versions change the output of medium compression slightly.
37-
libz-sys = { version = "=1.1.21", default-features = false, features = ["zlib-ng"] } # use libz-ng in libz compat mode
36+
libz-sys = { version = "1.1.23", default-features = false, features = ["zlib-ng"] } # use libz-ng in libz compat mode
3837
arbitrary = { version = "1.0" }
3938
quickcheck = { version = "1.0.3", default-features = false, features = [] }
4039

fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ features = ["arbitrary-derive"]
2424

2525
[dependencies]
2626
libc = "0.2.151"
27-
libz-ng-sys = "=1.1.21"
27+
libz-ng-sys = "1.1.23"
2828
libloading = "0.8.1"
2929
crc32fast = "1.3.2"
3030
rstest = "0.23.0"

test-libz-rs-sys/src/deflate.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,7 +1974,7 @@ mod fuzz_based_tests {
19741974
&input,
19751975
DeflateConfig::default(),
19761976
&[
1977-
120, 156, 19, 99, 24, 5, 12, 12, 12, 172, 32, 18, 0, 24, 45, 0, 28,
1977+
120, 156, 19, 99, 24, 5, 12, 12, 12, 172, 160, 80, 0, 0, 24, 45, 0, 28,
19781978
],
19791979
)
19801980
}
@@ -2600,7 +2600,7 @@ fn test_gzip_deflate_config() {
26002600
0,
26012601
],
26022602
name: CString::default(),
2603-
comment: CString::from(c"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"),
2603+
comment: CString::new(b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff").unwrap(),
26042604
hcrc: 1548508252,
26052605
},
26062606
};
@@ -2626,7 +2626,7 @@ fn test_gzip_deflate_config() {
26262626
config.mem_level,
26272627
config.strategy as i32,
26282628
zlibVersion(),
2629-
size_of::<z_stream>() as c_int,
2629+
core::mem::size_of::<z_stream>() as c_int,
26302630
)
26312631
};
26322632

zlib-rs/src/deflate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ pub(crate) struct State<'a> {
13021302
//
13031303
// Insert new strings in the hash table only if the match length is not
13041304
// greater than this length. This saves time but degrades compression.
1305-
// max_insert_length is used only for compression levels <= 3.
1305+
// max_insert_length is used only for compression levels <= 6.
13061306
// define max_insert_length max_lazy_match
13071307
/// Attempt to find a better match only when the current match is strictly smaller
13081308
/// than this value. This mechanism is used only for compression levels >= 4.

zlib-rs/src/deflate/algorithm/medium.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,11 @@ fn insert_match(state: &mut State, mut m: Match) {
230230
return;
231231
}
232232

233-
// Insert new strings in the hash table
234-
if state.lookahead >= WANT_MIN_MATCH {
233+
// Insert new strings in the hash table only if the match length
234+
// is not too large. This saves time but degrades compression.
235+
if usize::from(m.match_length) <= 16 * state.max_insert_length()
236+
&& state.lookahead >= WANT_MIN_MATCH
237+
{
235238
m.match_length -= 1; /* string at strstart already in table */
236239
m.strstart += 1;
237240

0 commit comments

Comments
 (0)