Skip to content

Commit

Permalink
make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
KillingSpark committed Oct 18, 2024
1 parent 7c595d7 commit 82694c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
9 changes: 4 additions & 5 deletions src/encoding/blocks/compressed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ fn compress_literals(literals: &[u8], writer: &mut BitWriter) {
_ => unimplemented!("too many literals"),
};

let encoded;
if size_format == 0 {
encoded = encoder.encode(literals);
let encoded = if size_format == 0 {
encoder.encode(literals)
} else {
encoded = encoder.encode4x(literals);
}
encoder.encode4x(literals)
};

writer.write_bits(size_format, 2);
writer.write_bits(literals.len() as u32, size_bits);
Expand Down
6 changes: 1 addition & 5 deletions src/fse/fse_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,7 @@ fn build_table_from_counts(counts: &[usize], max_log: u8, avoid_0_numbit: bool)

// find first occurence of the second_max to avoid lifting the last zero
let second_max = *probs.iter_mut().filter(|x| **x != max).max().unwrap();
let second_max = probs
.iter_mut()
.filter(|x| **x == second_max)
.next()
.unwrap();
let second_max = probs.iter_mut().find(|x| **x == second_max).unwrap();
*second_max += redistribute;
assert!(*second_max <= max);
}
Expand Down
5 changes: 2 additions & 3 deletions src/huff0/huff0_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@ impl HuffmanEncoder {
if weights.len() > 16 {
// TODO share output vec between encoders
// TODO assert that no 0 num_bit states are generated here
let mut encoder =
FSEEncoder::new(fse_encoder::build_table_from_data(&weights, 6, true));
let encoded = encoder.encode_interleaved(&weights);
let mut encoder = FSEEncoder::new(fse_encoder::build_table_from_data(weights, 6, true));
let encoded = encoder.encode_interleaved(weights);
assert!(encoded.len() < 128);
self.writer.write_bits(encoded.len() as u8, 8);
self.writer.append_bytes(&encoded);
Expand Down

0 comments on commit 82694c6

Please sign in to comment.