Skip to content

Commit

Permalink
dry common code
Browse files Browse the repository at this point in the history
  • Loading branch information
KillingSpark committed Oct 21, 2024
1 parent ac32d6d commit ade1b3d
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/encoding/blocks/compressed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ pub fn compress_block(data: &[u8], output: &mut Vec<u8>) {
let mut writer = BitWriter::from(output);
compress_literals(data, &mut writer);
//raw_literals(data, &mut writer);
//sequences
writer.write_bits(0u8, 8);
writer.flush();
}

Expand All @@ -16,9 +18,6 @@ fn raw_literals(literals: &[u8], writer: &mut BitWriter<&mut Vec<u8>>) {
writer.write_bits(0b11u8, 2);
writer.write_bits(literals.len() as u32, 20);
writer.append_bytes(literals);

//sequences
writer.write_bits(0u8, 8);
}

fn compress_literals(literals: &[u8], writer: &mut BitWriter<&mut Vec<u8>>) {
Expand Down Expand Up @@ -47,7 +46,4 @@ fn compress_literals(literals: &[u8], writer: &mut BitWriter<&mut Vec<u8>>) {
};
let encoded_len = (writer.index() - index_before) / 8;
writer.change_bits(size_index, encoded_len as u64, size_bits);

//sequences
writer.write_bits(0u8, 8);
}

0 comments on commit ade1b3d

Please sign in to comment.