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 reader allocation for compressors pools #792

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

emcfarlane
Copy link
Contributor

Small optimization to avoid allocating a new reader when recycling compressors by using http.NoBody.

Small optimization to avoid allocating a new reader when recycling
compressors by using `http.NoBody`.

Signed-off-by: Edward McFarlane <[email protected]>
@emcfarlane emcfarlane requested a review from jhump October 28, 2024 15:27
@@ -147,7 +148,7 @@ func (c *compressionPool) putDecompressor(decompressor Decompressor) error {
// know the compression format, we can't provide a valid header. Since we
// also reset the decompressor when it's pulled out of the pool, we can
// ignore errors here.
_ = decompressor.Reset(strings.NewReader(""))
_ = decompressor.Reset(http.NoBody)
Copy link
Member

Choose a reason for hiding this comment

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

😻 Love the attention to detail here.

@emcfarlane emcfarlane merged commit 74a6754 into main Oct 28, 2024
15 checks passed
@emcfarlane emcfarlane deleted the ed/noBodyCompressors branch October 28, 2024 17:29
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