Skip to content

Commit

Permalink
fix table insert
Browse files Browse the repository at this point in the history
  • Loading branch information
a10y committed Aug 15, 2024
1 parent 75acb6c commit 3bfff50
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 26 deletions.
23 changes: 0 additions & 23 deletions benches/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,6 @@ fn bench_fsst(c: &mut Criterion) {
fn bench_lz4(c: &mut Criterion) {
let mut group = c.benchmark_group("lz4");

// {
// let compressed = Vec::with_capacity(10_000);
// let mut encoder = lz4::EncoderBuilder::new()
// .block_size(BlockSize::Max64KB)
// .build(compressed)
// .unwrap();
//
// encoder.write_all(TEST.as_bytes()).unwrap();
// let (compressed, result) = encoder.finish();
// result.unwrap();
//
// let ratio = (TEST.as_bytes().len() as f64) / (compressed.len() as f64);
// println!("LZ4 compress_ratio = {ratio}");
//
// // ensure decodes cleanly
// let cursor = Cursor::new(compressed);
// let mut decoder = lz4::Decoder::new(cursor).unwrap();
// let mut output = String::new();
//
// decoder.read_to_string(&mut output).unwrap();
// assert_eq!(output.as_str(), TEST);
// }

group.bench_function("compress-single", |b| {
let mut compressed = Vec::with_capacity(100_000_000);
let mut encoder = lz4::EncoderBuilder::new()
Expand Down
1 change: 0 additions & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ impl SymbolTable {
let mut pos = self.symbols[prev_code as usize].len();

while pos < len {
println!("loop pos = {pos} len = {len}");
let code = self.find_longest_symbol(&sample[pos..len]);
counter.record_count1(code);
counter.record_count2(prev_code, code);
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ impl SymbolTable {
} else if symbol_len >= 3 {
// Attempt to insert larger symbols into the 3-byte cache
if !self.lossy_pht.insert(symbol, self.n_symbols) {
println!("table insert rejected");
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lossy_pht.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl LossyPHT {
let slot = self.hash(prefix_3bytes) as usize & (HASH_TABLE_SIZE - 1);
let entry = &mut self.slots[slot];

if entry.is_unused() {
if !entry.is_unused() {
false
} else {
entry.symbol = symbol;
Expand Down

0 comments on commit 3bfff50

Please sign in to comment.