Skip to content

Commit 4ae3517

Browse files
brianpanefolkertdev
authored andcommitted
Add some comments explaining the chained hash data structure.
1 parent 067e217 commit 4ae3517

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

zlib-rs/src/deflate.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,14 @@ pub(crate) struct State<'a> {
13141314
pub(crate) w_mask: usize, /* w_size - 1 */
13151315
pub(crate) lookahead: usize, /* number of valid bytes ahead in window */
13161316

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

13201327
/// hash index of string to be inserted

0 commit comments

Comments
 (0)