Skip to content

Commit 7216de7

Browse files
committed
specialize inflate_fast_help for avx2
1 parent 1c5ad01 commit 7216de7

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

zlib-rs/src/inflate.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,27 @@ 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+
#[target_feature(enable = "avx2")]
1870+
unsafe fn inflate_fast_help_avx2(state: &mut State, start: usize) {
1871+
inflate_fast_help_impl(state, start);
1872+
}
1873+
1874+
fn inflate_fast_help_vanilla(state: &mut State, start: usize) {
1875+
inflate_fast_help_impl(state, start);
1876+
}
1877+
1878+
#[inline(always)]
1879+
fn inflate_fast_help_impl(state: &mut State, _start: usize) {
18601880
let mut bit_reader = BitReader::new(&[]);
18611881
core::mem::swap(&mut bit_reader, &mut state.bit_reader);
18621882

0 commit comments

Comments
 (0)