-
Notifications
You must be signed in to change notification settings - Fork 69
Added legacy shrink/reduce/implode compression. #303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looks good; just some nitpicks.
ty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are failing because a new dependency requires Rust 1.79. You can increase the MSRV for zip to 1.79 to fix this, or replace the dependency if that's somehow easier.
Co-authored-by: Chris Hennick <[email protected]> Signed-off-by: Mike Krüger <[email protected]>
Head branch was pushed to by a user without write access
1125d37
to
eaeccf6
Compare
Updated to bitstream-io 2.6.0 + upped rust version. |
Signed-off-by: Mike Krüger <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, but still a fair number of nitpicks.
/// | ||
/// # Returns | ||
/// | ||
/// * `Ok(())` if the byte was successfully read. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// * `Ok(())` if the byte was successfully read. | |
/// * `Ok` with the byte if it was successfully read. |
|
||
struct CodeQueue { | ||
next_idx: usize, | ||
codes: [Option<u16>; MAX_CODE - CONTROL_CODE + 1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Factor out a constant for MAX_CODE - CONTROL_CODE + 1
(maybe called CODE_ARRAY_LEN
).
impl CodeQueue { | ||
fn new() -> Self { | ||
let mut codes = [None; MAX_CODE as usize - CONTROL_CODE + 1]; | ||
for (i, code) in (CONTROL_CODE as u16 + 1..=MAX_CODE as u16).enumerate() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need clarifying parentheses here as well.
} | ||
|
||
impl Codetab { | ||
pub fn create_new() -> [Self; MAX_CODE + 1] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a slice [Codetab::default(); MAX_CODE + 1]
and just overwrite the first 0..=u8::MAX
entries. This will probably be more efficient because it eliminates the heap allocation and reallocation.
@@ -10,7 +10,7 @@ authors = [ | |||
license = "MIT" | |||
repository = "https://github.com/zip-rs/zip2.git" | |||
keywords = ["zip", "archive", "compression"] | |||
rust-version = "1.73.0" | |||
rust-version = "1.83.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is version 1.83.0 needed? I won't release this change until the MSRV has been stable for 6 months; for 1.83.0 that would mean 2025-05-28.
Also, an MSRV change needs to be reflected in README.md
and .github/workflows/ci.yaml
; the latter is why CI is failing for this PR.
let mut is_prefix = [false; MAX_CODE + 1]; | ||
|
||
// Scan for codes that have been used as a prefix. | ||
for i in CONTROL_CODE + 1..=MAX_CODE { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need clarifying parentheses.
} | ||
|
||
/// Read the next code from the input stream and return it in next_code. Returns | ||
/// false if the end of the stream is reached. If the stream contains invalid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// false if the end of the stream is reached. If the stream contains invalid | |
/// `Ok(None)` if the end of the stream is reached. If the stream contains invalid |
|
||
/// Read the next code from the input stream and return it in next_code. Returns | ||
/// false if the end of the stream is reached. If the stream contains invalid | ||
/// data, next_code is set to INVALID_CODE but the return value is still true. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// data, next_code is set to INVALID_CODE but the return value is still true. | |
/// data, returns `Err`. |
let mut code_size = MIN_CODE_SIZE; | ||
|
||
// Handle the first code separately since there is no previous code. | ||
let Ok(Some(curr_code)) = read_code(&mut is, &mut code_size, &mut codetab, &mut queue) else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this pass through any error it receives? (Use the ?
operator to do that.)
@@ -0,0 +1,2 @@ | |||
#67h���<D��������P!T�oՖK�Ѻt˺[V�Y�E��}��[� ��m˶,]� ��y5-[�i�7ȩhî-;nٰr���Mmڹ ˼7�7�V.H�h˂�;����6�[�e�����·��^�m�tM&Y�c��t?c�������o8ٚ���>�@k6��|�t����~���A�l����_� |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Git still thinks this is a text file.
Signed-off-by: Chris Hennick <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my previous review; GitHub didn't think it was finished for some reason.
Replaces #120
The original PR grew too large to sanely merge it - ported it manually to zip-rs HEAD and reopened the PR.
I need the legacy formats for my BBS project which I've not touched for some while but I've continued on that lately.