Skip to content

Commit 95b9be0

Browse files
committed
specialize inflate_fast_help for avx2
1 parent 1c5ad01 commit 95b9be0

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

zlib-rs/src/inflate.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,28 @@ impl State<'_> {
18561856
}
18571857
}
18581858

1859-
fn inflate_fast_help(state: &mut State, _start: usize) {
1859+
fn inflate_fast_help(state: &mut State, start: usize) {
1860+
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
1861+
if crate::cpu_features::is_enabled_avx2() {
1862+
// SAFETY: we've verified the target features
1863+
return unsafe { inflate_fast_help_avx2(state, start) };
1864+
}
1865+
1866+
inflate_fast_help_vanilla(state, start);
1867+
}
1868+
1869+
#[cfg(any(target_arch = "x86_64", target_arch = "x86"))]
1870+
#[target_feature(enable = "avx2")]
1871+
unsafe fn inflate_fast_help_avx2(state: &mut State, start: usize) {
1872+
inflate_fast_help_impl(state, start);
1873+
}
1874+
1875+
fn inflate_fast_help_vanilla(state: &mut State, start: usize) {
1876+
inflate_fast_help_impl(state, start);
1877+
}
1878+
1879+
#[inline(always)]
1880+
fn inflate_fast_help_impl(state: &mut State, _start: usize) {
18601881
let mut bit_reader = BitReader::new(&[]);
18611882
core::mem::swap(&mut bit_reader, &mut state.bit_reader);
18621883

0 commit comments

Comments
 (0)