Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions zlib-rs/src/deflate/slide_hash.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
pub fn slide_hash(state: &mut crate::deflate::State) {
let wsize = state.w_size as u16;

// The state.head and state.prev slices have a length that is a power of 2 between 8 and 16.
// That knowledge means `chunks_exact` with a (small) power of 2 can be used without risk of
// missing elements.
slide_hash_chain(state.head.as_mut_slice(), wsize);
slide_hash_chain(state.prev.as_mut_slice(), wsize);
}
Expand All @@ -26,8 +29,10 @@ fn slide_hash_chain(table: &mut [u16], wsize: u16) {

mod rust {
pub fn slide_hash_chain(table: &mut [u16], wsize: u16) {
for m in table.iter_mut() {
*m = m.saturating_sub(wsize);
for chunk in table.chunks_exact_mut(32) {
for m in chunk.iter_mut() {
*m = m.saturating_sub(wsize);
}
}
}
}
Expand Down
Loading