Skip to content

Commit

Permalink
Remove reader allocation for compressors pools (#792)
Browse files Browse the repository at this point in the history
Small optimization to avoid allocating a new reader when recycling
compressors by using `http.NoBody`.

Signed-off-by: Edward McFarlane <[email protected]>
  • Loading branch information
emcfarlane authored Oct 28, 2024
1 parent 6029bf7 commit 74a6754
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compression.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"errors"
"io"
"math"
"net/http"
"strings"
"sync"
)
Expand Down Expand Up @@ -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)
c.decompressors.Put(decompressor)
return nil
}
Expand Down

0 comments on commit 74a6754

Please sign in to comment.