Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: CI

jobs:
tests:
name: Check
name: stable lint, test, build
runs-on: ubuntu-latest
steps:
- name: Checkout sources
Expand All @@ -14,16 +14,23 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Install cargo-hack
- name: Install cargo-hack and cargo-msrv
uses: taiki-e/install-action@v2
with:
tool: cargo-hack
- run: cargo hack check --workspace --feature-powerset --exclude-features rustc-dep-of-std
- run: cargo hack clippy --workspace --feature-powerset --exclude-features rustc-dep-of-std
- run: cargo hack test --workspace --feature-powerset --exclude-features rustc-dep-of-std
tool: cargo-hack, cargo-msrv
- name: check
run: cargo hack check --workspace --feature-powerset --exclude-features rustc-dep-of-std
- name: cargo hack clippy
run: cargo hack clippy --workspace --feature-powerset --exclude-features rustc-dep-of-std
- name: cargo hack test
run: cargo hack test --workspace --feature-powerset --exclude-features rustc-dep-of-std
- name: Verify MSRV (cli)
run: cargo msrv verify --path cli/
- name: Verify MSRV (lib)
run: cargo msrv verify --path ruzstd/

nightly-stuff:
name: nightly clippy, format and miri tests
name: nightly lint, miri
runs-on: ubuntu-latest
steps:
- name: Checkout sources
Expand All @@ -39,4 +46,3 @@ jobs:
- run: cargo +nightly clippy --workspace -- -D warnings
- run: cargo +nightly miri test ringbuffer
- run: cargo +nightly miri test short_Writer

1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This document records the changes made between versions, starting with version 0.5.0

# After 0.8.2 (Current)
* Introduce the `rust-version` field

# After 0.8.1
* The CLI has been refactored to use `clap`
Expand Down
5 changes: 3 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

[package]
name = "ruzstd-cli"
version = "0.8.1"
version = "0.8.2"
rust-version = "1.87.0"
authors = ["Moritz Borcherding <moritz.borcherding@web.de>"]
edition = "2018"
license = "MIT"
Expand All @@ -26,4 +27,4 @@ ruzstd = { path = "../ruzstd", features = ["std"] }
[dev-dependencies]
criterion = "0.5"
rand = { version = "0.8.5", features = ["small_rng"] }
zstd = "0.13.2"
zstd = "0.13.2"
3 changes: 1 addition & 2 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use progress::ProgressMonitor;

use std::fs::File;
use std::io::BufReader;
use std::os::unix::fs::MetadataExt;
use std::path::Path;
use std::path::PathBuf;

Expand Down Expand Up @@ -134,7 +133,7 @@ fn compress(input: PathBuf, output: PathBuf, level: u8) -> color_eyre::Result<()
fn decompress(input: PathBuf, output: PathBuf) -> color_eyre::Result<()> {
info!("extracting {input:?} to {output:?}");
let source_file = File::open(input).wrap_err("failed to open input file")?;
let source_size = source_file.metadata()?.size() as usize;
let source_size = source_file.metadata()?.len() as usize;
let buffered_source = BufReader::new(source_file);
let decoder_input = ProgressMonitor::new(buffered_source, source_size);
let mut output: File =
Expand Down
3 changes: 2 additions & 1 deletion ruzstd/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[package]
name = "ruzstd"
version = "0.8.2"
version = "0.8.3"
rust-version = "1.87"
authors = ["Moritz Borcherding <moritz.borcherding@web.de>"]
edition = "2018"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion ruzstd/src/decoding/ringbuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl RingBuffer {

self.reserve(len);

debug_assert!(self.len() + len <= self.cap - 1);
debug_assert!(self.len() + len < self.cap);
debug_assert!(self.free() >= len, "free: {} len: {}", self.free(), len);

let ((f1_ptr, f1_len), (f2_ptr, f2_len)) = self.free_slice_parts();
Expand Down
12 changes: 6 additions & 6 deletions ruzstd/src/decoding/sequence_section_decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ fn decode_sequences_with_rle(

for _seq_idx in 0..section.num_sequences {
//get the codes from either the RLE byte or from the decoder
let ll_code = if scratch.ll_rle.is_some() {
scratch.ll_rle.unwrap()
let ll_code = if let Some(ll_rle) = scratch.ll_rle {
ll_rle
} else {
ll_dec.decode_symbol()
};
let ml_code = if scratch.ml_rle.is_some() {
scratch.ml_rle.unwrap()
let ml_code = if let Some(ml_rle) = scratch.ml_rle {
ml_rle
} else {
ml_dec.decode_symbol()
};
let of_code = if scratch.of_rle.is_some() {
scratch.of_rle.unwrap()
let of_code = if let Some(of_rle) = scratch.of_rle {
of_rle
} else {
of_dec.decode_symbol()
};
Expand Down
4 changes: 2 additions & 2 deletions ruzstd/src/fse/fse_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ pub(super) fn build_table_from_probabilities(probs: &[i32], acc_log: u8) -> FSET
let state = &mut states[symbol];

// We process the states in their order in the table
state.states.sort_by(|l, r| l.index.cmp(&r.index));
state.states.sort_by_key(|l| l.index);

let prob_log = if prob.is_power_of_two() {
prob.ilog2()
Expand Down Expand Up @@ -401,7 +401,7 @@ pub(super) fn build_table_from_probabilities(probs: &[i32], acc_log: u8) -> FSET
}

// For encoding we use the states ordered by the indexes they target
state.states.sort_by(|l, r| l.baseline.cmp(&r.baseline));
state.states.sort_by_key(|l| l.baseline);
}

FSETable {
Expand Down
2 changes: 1 addition & 1 deletion ruzstd/src/huff0/huff0_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl HuffmanTable {

weights.reverse();
let mut counts_sorted = counts.iter().enumerate().collect::<Vec<_>>();
counts_sorted.sort_by(|(_, c1), (_, c2)| c1.cmp(c2));
counts_sorted.sort_by_key(|(_, c1)| *c1);

let mut weights_distributed = alloc::vec![0; counts.len()];
for (idx, count) in counts_sorted {
Expand Down