Skip to content

Commit

Permalink
Add some comments explaining the chained hash data structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianpane authored and folkertdev committed Dec 20, 2024
1 parent 067e217 commit 4ae3517
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions zlib-rs/src/deflate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,14 @@ pub(crate) struct State<'a> {
pub(crate) w_mask: usize, /* w_size - 1 */
pub(crate) lookahead: usize, /* number of valid bytes ahead in window */

/// prev[N], where N is an offset in the current window, contains the offset in the window
/// of the previous 4-byte sequence that hashes to the same value as the 4-byte sequence
/// starting at N. Together with head, prev forms a chained hash table that can be used
/// to find earlier strings in the window that are potential matches for new input being
/// deflated.
pub(crate) prev: WeakSliceMut<'a, u16>,
/// head[H] contains the offset of the last 4-character sequence seen so far in
/// the current window that hashes to H (as calculated using the hash_calc_variant).
pub(crate) head: WeakArrayMut<'a, u16, HASH_SIZE>,

/// hash index of string to be inserted
Expand Down

0 comments on commit 4ae3517

Please sign in to comment.