Skip to content

Commit

Permalink
add single bytes as candidates
Browse files Browse the repository at this point in the history
  • Loading branch information
a10y committed Aug 21, 2024
1 parent d15cc4e commit c0b48de
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ impl Compressor {
counter.record_count1(code);
counter.record_count2(prev_code, code);

// Record the first byte of `code` as its own symbol so that it is a candidate for merging
// with `prev_code`. This allows us to grow the symbol table by one byte rather than
// concatenating a full symbol.
if code >= 256 {
let first_byte = self.symbols[code as usize].first_byte();
counter.record_count2(prev_code, first_byte as u16);
}

prev_code = code;
}
}
Expand Down

0 comments on commit c0b48de

Please sign in to comment.