Skip to content
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

Remove double bounds check #77

Merged
merged 2 commits into from
Jan 14, 2025
Merged

Remove double bounds check #77

merged 2 commits into from
Jan 14, 2025

Conversation

folkertdev
Copy link
Collaborator

No description provided.

@folkertdev folkertdev requested a review from bjorn3 January 14, 2025 09:49
Copy link

codecov bot commented Jan 14, 2025

Codecov Report

Attention: Patch coverage is 84.61538% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
libbz2-rs-sys/src/decompress.rs 84.61% 6 Missing ⚠️
Files with missing lines Coverage Δ
libbz2-rs-sys/src/decompress.rs 93.52% <84.61%> (-0.07%) ⬇️

Comment on lines +767 to +771
let index = zvec - s.base[gBase as usize][zn as usize];
nextSym = match s.perm[gPerm as usize].get(index as usize) {
Some(&nextSym) => nextSym,
None => error!(BZ_DATA_ERROR),
};
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the s.perm[i] arrays are 258 elements long, so the check for the index value to be in bounds was happening twice (though of course llvm might optimize that out)

Comment on lines +358 to +362
match uc {
0x17 => current_block = BZ_X_ENDHDR_2,
0x31 => current_block = BZ_X_BLKHDR_2,
_ => error!(BZ_DATA_ERROR),
};
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just a cleanup that i spotted

Comment on lines -1288 to -1289
groupNo = -1;
groupPos = 0;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved over to hopefully make it clearer why groupNo cannot be unsigned (currently anyway, maybe with some extra refactoring).

@folkertdev folkertdev merged commit 0f61d83 into main Jan 14, 2025
20 of 21 checks passed
@folkertdev folkertdev deleted the remove-double-bounds-check branch January 14, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants