Skip to content

perf: change passthrough compressor to avoid allocation#249

Open
mikhailofff wants to merge 1 commit intohit-box:mainfrom
mikhailofff:fix/issue-220
Open

perf: change passthrough compressor to avoid allocation#249
mikhailofff wants to merge 1 commit intohit-box:mainfrom
mikhailofff:fix/issue-220

Conversation

@mikhailofff
Copy link

Summary

  • Change compress(&[u8]) -> Vec to compress(&[u8]) -> Cow<[u8]> so passthrough compressor avoids allocation.
  • Change decompress(&[u8]) -> Vec to decompress(&[u8]) -> Cow<[u8]> as well.

Closes #220.

@AndreyErmilov
Copy link
Contributor

Hi @mikhailofff! Sorry for the late response, and thanks for your PR!
Regarding the code - I think Cow should use the ownership pattern here, since the compressor takes ownership. This would be semantically more correct.

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.

Compressor: return Cow<[u8]> for zero-copy passthrough

2 participants