Skip to content

Conversation

@folkertdev
Copy link
Member

attempt to read up to 7 bytes at once, cutting down on the total number of reads. This has some nice performance benefits.

@codecov
Copy link

codecov bot commented Jan 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ
libbz2-rs-sys/src/bzlib.rs 92.97% <100.00%> (+0.34%) ⬆️
libbz2-rs-sys/src/decompress.rs 94.21% <100.00%> (+0.06%) ⬆️

@folkertdev folkertdev requested a review from bjorn3 January 22, 2025 09:56
if self.avail_in < 8 {
return None;
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add a debug assertion that no more than 7 bytes are requested? And no more than 1 byte in the case of pull_u8.

Copy link
Member Author

Choose a reason for hiding this comment

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

well I added an assert that we can at least consume 1 additional byte, in other words that we don't ask for more input if we don't have space in the bit buffer.

The check you comment on is a bounds check, so we just skip this function if there are not 8 additional bytes in the input, there is nothing to assert there right?

@folkertdev folkertdev force-pushed the decompress-faster-input-reading branch from 6dd666f to c78469e Compare January 22, 2025 10:44
@folkertdev folkertdev merged commit d5d181b into main Jan 22, 2025
21 checks passed
@folkertdev folkertdev deleted the decompress-faster-input-reading branch January 22, 2025 12:27
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.

3 participants