Skip to content

Commit 1217b45

Browse files
brianpanefolkertdev
authored andcommitted
Make State::ins_h u32
1 parent 0b849cb commit 1217b45

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

zlib-rs/src/deflate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ pub(crate) struct State<'a> {
13511351
pub(crate) head: WeakArrayMut<'a, u16, HASH_SIZE>,
13521352

13531353
/// hash index of string to be inserted
1354-
pub(crate) ins_h: usize,
1354+
pub(crate) ins_h: u32,
13551355

13561356
crc_fold: crate::crc32::Crc32Fold,
13571357
gzhead: Option<&'a mut gz_header>,
@@ -1802,7 +1802,7 @@ pub(crate) fn fill_window(stream: &mut DeflateStream) {
18021802
if state.max_chain_length > 1024 {
18031803
let v0 = state.window.filled()[string] as u32;
18041804
let v1 = state.window.filled()[string + 1] as u32;
1805-
state.ins_h = state.update_hash(v0, v1) as usize;
1805+
state.ins_h = state.update_hash(v0, v1);
18061806
} else if string >= 1 {
18071807
state.quick_insert_string(string + 2 - STD_MIN_MATCH);
18081808
}

zlib-rs/src/deflate/hash_calc.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ impl RollHashCalc {
9191
pub fn quick_insert_string(state: &mut State, string: usize) -> u16 {
9292
let val = state.window.filled()[string + Self::HASH_CALC_OFFSET] as u32;
9393

94-
state.ins_h = Self::hash_calc(state.ins_h as u32, val) as usize;
95-
state.ins_h &= Self::HASH_CALC_MASK as usize;
94+
state.ins_h = Self::hash_calc(state.ins_h, val);
95+
state.ins_h &= Self::HASH_CALC_MASK;
9696

97-
let hm = state.ins_h;
97+
let hm = state.ins_h as usize;
9898

9999
let head = state.head.as_slice()[hm];
100100
if head != string as u16 {
@@ -111,9 +111,9 @@ impl RollHashCalc {
111111
for (i, val) in slice.iter().copied().enumerate() {
112112
let idx = string as u16 + i as u16;
113113

114-
state.ins_h = Self::hash_calc(state.ins_h as u32, val as u32) as usize;
115-
state.ins_h &= Self::HASH_CALC_MASK as usize;
116-
let hm = state.ins_h;
114+
state.ins_h = Self::hash_calc(state.ins_h, val as u32);
115+
state.ins_h &= Self::HASH_CALC_MASK;
116+
let hm = state.ins_h as usize;
117117

118118
let head = state.head.as_slice()[hm];
119119
if head != idx {

0 commit comments

Comments
 (0)