diff --git a/zlib-rs/src/deflate/algorithm/quick.rs b/zlib-rs/src/deflate/algorithm/quick.rs index 4b397ff..c7b3526 100644 --- a/zlib-rs/src/deflate/algorithm/quick.rs +++ b/zlib-rs/src/deflate/algorithm/quick.rs @@ -100,7 +100,12 @@ pub fn deflate_quick(stream: &mut DeflateStream, flush: DeflateFlush) -> BlockSt let str_start = &state.window.filled()[state.strstart..]; let match_start = &state.window.filled()[hash_head as usize..]; - if str_start[0] == match_start[0] && str_start[1] == match_start[1] { + macro_rules! first_two_bytes { + ($slice:expr, $offset:expr) => { + $slice[$offset] as u16 | ($slice[$offset + 1] as u16) << 8 + } + } + if first_two_bytes!(str_start, 0) == first_two_bytes!(match_start, 0) { let mut match_len = crate::deflate::compare256::compare256_slice( &str_start[2..], &match_start[2..],