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

Consolidate fields of decompressor #46

Merged

Conversation

anforowicz
Copy link
Contributor

@fintelia, can you PTAL?

I hope that these 4 commits are mostly non-controversial (or at least much less controversial than the incomplete follow-up here for experimenting with dynamic table sizes).

This PR is motivated by the desire to experiment (in a separate follow-up, just in my local repo for now) with moving fn read_compressed into an instance method of CompressedBlock (currently this is a method of Decompressor). And making it a method of CompressedBlock would help with supporting various table sizes by making CompressedBlock a const-generic, while exposing fn read_compressed through a dyn CompressedBlockHandler trait.

I wondered whether to also change output_index parameter of fn read_compressed to &mut usize (and avoid returning the new/final value of this parameter). But I guess this would be unnecessary change = unnecessary risk (maybe this matters for performance). So let's just do the simplest thing for now?

Similarily, BitBuffer could be more encapsulated (e.g. living in a separate submodule), but again - this is not needed and at this point would seem like an unnecessary complication.

Note that in the 4th/final commit I can replace break with return Ok(...), because before break-ing we change self.state to something other than State::CompressedData - and the subsequent while and if check that self.state == State::CompressedData.

@kornelski kornelski merged commit 1d4d356 into image-rs:main Jan 4, 2025
10 checks passed
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