impl HashCalcVariant { /// Use rolling hash for deflate_slow algorithm with level 9. It allows us to /// properly lookup different hash chains to speed up longest_match search. pubfn for_max_chain_length(max_chain_length: u16) -> Self { if max_chain_length > 1024 {
HashCalcVariant::Roll
} else {
HashCalcVariant::Standard
}
}
}
#[inline] pubfn quick_insert_string(state: &mut State, string: usize) -> u16 { let slice = &state.window.filled()[string + Self::HASH_CALC_OFFSET..]; let val = u32::from_le_bytes(slice[..4].try_into().unwrap());
Self::quick_insert_value(state, string, val)
}
#[inline] pubfn quick_insert_value(state: &mut State, string: usize, val: u32) -> u16 { let hm = Self::update_hash(0, val) as usize;
let head = state.head.as_slice()[hm]; if head != string as u16 {
state.prev.as_mut_slice()[string & state.w_mask()] = head;
state.head.as_mut_slice()[hm] = string as u16;
}
// it can happen that insufficient bytes are initialized // .take(count) generates worse assembly let slice = &slice[..Ord::min(slice.len(), count + 3)];
let w_mask = state.w_mask(); for (i, w) in slice.windows(4).enumerate() { let idx = string as u16 + i as u16;
let val = u32::from_le_bytes(w.try_into().unwrap());
let hm = Self::update_hash(0, val) as usize;
let head = state.head.as_slice()[hm]; if head != idx {
state.prev.as_mut_slice()[idx as usize & w_mask] = head;
state.head.as_mut_slice()[hm] = idx;
}
}
}
}
let head = state.head.as_slice()[hm]; if head != string as u16 {
state.prev.as_mut_slice()[string & state.w_mask()] = head;
state.head.as_mut_slice()[hm] = string as u16;
}
let w_mask = state.w_mask(); for (i, val) in slice.iter().copied().enumerate() { let idx = string as u16 + i as u16;
state.ins_h = Self::hash_calc(state.ins_h, val as u32);
state.ins_h &= Self::HASH_CALC_MASK; let hm = state.ins_h as usize;
let head = state.head.as_slice()[hm]; if head != idx {
state.prev.as_mut_slice()[idx as usize & w_mask] = head;
state.head.as_mut_slice()[hm] = idx;
}
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.