File tree 1 file changed +7
-12
lines changed
zlib-rs/src/deflate/algorithm
1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -97,20 +97,15 @@ pub fn deflate_quick(stream: &mut DeflateStream, flush: DeflateFlush) -> BlockSt
97
97
let dist = state. strstart as isize - hash_head as isize ;
98
98
99
99
if dist <= state. max_dist ( ) as isize && dist > 0 {
100
- let str_start = & state. window . filled ( ) [ state. strstart ..] ;
101
- let match_start = & state. window . filled ( ) [ hash_head as usize ..] ;
100
+ let str_start = & state. window . filled ( ) [ state. strstart ..] [ .. 258 ] ;
101
+ let match_start = & state. window . filled ( ) [ hash_head as usize ..] [ .. 258 ] ;
102
102
103
- macro_rules! first_two_bytes {
104
- ( $slice: expr, $offset: expr) => {
105
- u16 :: from_le_bytes( $slice[ $offset..$offset + 2 ] . try_into( ) . unwrap( ) )
106
- } ;
107
- }
103
+ let ( prefix1, tail1) = str_start. split_at ( 2 ) ;
104
+ let ( prefix2, tail2) = match_start. split_at ( 2 ) ;
108
105
109
- if first_two_bytes ! ( str_start, 0 ) == first_two_bytes ! ( match_start, 0 ) {
110
- let mut match_len = crate :: deflate:: compare256:: compare256_slice (
111
- & str_start[ 2 ..] ,
112
- & match_start[ 2 ..] ,
113
- ) + 2 ;
106
+ if prefix1 == prefix2 {
107
+ let mut match_len =
108
+ 2 + crate :: deflate:: compare256:: compare256_slice ( tail1, tail2) ;
114
109
115
110
if match_len >= WANT_MIN_MATCH {
116
111
match_len = Ord :: min ( match_len, state. lookahead ) ;
You can’t perform that action at this time.
0 commit comments