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

Caller passes in dst to decompress #125

Merged
merged 1 commit into from
Jan 14, 2024

Conversation

garymm
Copy link
Owner

@garymm garymm commented Jan 13, 2024

Caller passes in dst to decompress

This avoids allocation inside decompress.

Also:

  • Doxygen style comments for public interface.
  • Move decompress implementation to .cpp since it is no longer
    templated.
  • Move checking of final to the top of the loop.

Change-Id: I4afa1e306c5d20c1a83d3173292b77ab6e8fc01c

@garymm garymm marked this pull request as ready for review January 13, 2024 15:45
@garymm garymm requested a review from oliverlee January 13, 2024 15:46
Copy link

codecov bot commented Jan 13, 2024

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (c1636cd) 82.32% compared to head (6ee5b24) 82.29%.

Files Patch % Lines
src/decompress.cpp 76.31% 6 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #125      +/-   ##
==========================================
- Coverage   82.32%   82.29%   -0.03%     
==========================================
  Files          17       16       -1     
  Lines         628      627       -1     
  Branches       37       38       +1     
==========================================
- Hits          517      516       -1     
  Misses         94       94              
  Partials       17       17              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@garymm garymm force-pushed the I4afa1e306c5d20c1a83d3173292b77ab6e8fc01c branch from 383b58c to 4b68cb5 Compare January 13, 2024 17:23
Copy link
Collaborator

@oliverlee oliverlee left a comment

Choose a reason for hiding this comment

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

Some comments about addressing sad path cases.

Those mostly align with the missing coverage from this patch.

Not sure if you wanted to address those in a follow-up but it's approved if that's the case.

src/decompress.cpp Show resolved Hide resolved
src/decompress.cpp Show resolved Hide resolved
if (header->type == NoCompression) { // no compression
// Any bits of input up to the next byte boundary are ignored.
src_bits.consume_to_byte_boundary();
const std::uint16_t len = src_bits.pop_16();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we know the input is large enough to store this?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Guessing you mean "Do we know src_bits.size() >= 16"?

bit_span.pop() asserts that, but we should probably handle it here, in the same way that we handle the "not enough bits in src" issue below. I'll do that in another PR, this one is getting a little big.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah exactly

src/decompress.cpp Outdated Show resolved Hide resolved
src/decompress.cpp Show resolved Hide resolved
src/decompress.cpp Outdated Show resolved Hide resolved
@garymm garymm force-pushed the I4afa1e306c5d20c1a83d3173292b77ab6e8fc01c branch from 4b68cb5 to c29dd8c Compare January 13, 2024 19:28
Copy link
Owner Author

@garymm garymm left a comment

Choose a reason for hiding this comment

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

Thanks for the quick review. Missing coverage is mostly not actually new, just seems like it because I moved from .hpp to .cpp. Probably should have done that in 2 commits.

src/decompress.cpp Show resolved Hide resolved
if (header->type == NoCompression) { // no compression
// Any bits of input up to the next byte boundary are ignored.
src_bits.consume_to_byte_boundary();
const std::uint16_t len = src_bits.pop_16();
Copy link
Owner Author

Choose a reason for hiding this comment

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

Guessing you mean "Do we know src_bits.size() >= 16"?

bit_span.pop() asserts that, but we should probably handle it here, in the same way that we handle the "not enough bits in src" issue below. I'll do that in another PR, this one is getting a little big.

src/decompress.cpp Show resolved Hide resolved
This avoids allocation inside decompress.

Also:
* Doxygen style comments for public interface.
* Move decompress implementation to .cpp since it is no longer
  templated.
* Move checking of final to the top of the loop.

Change-Id: I4afa1e306c5d20c1a83d3173292b77ab6e8fc01c
@garymm garymm force-pushed the I4afa1e306c5d20c1a83d3173292b77ab6e8fc01c branch from c29dd8c to 6ee5b24 Compare January 13, 2024 23:42
@garymm
Copy link
Owner Author

garymm commented Jan 14, 2024

@oliverlee I made some fairly significant changes in response to your feedback. I'll merge now but feel free to add comments and I'll respond later.

@garymm garymm merged commit 2e6a83d into master Jan 14, 2024
13 of 15 checks passed
@garymm garymm deleted the I4afa1e306c5d20c1a83d3173292b77ab6e8fc01c branch January 14, 2024 00:19
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