aboutsummaryrefslogtreecommitdiff
path: root/internal/flatex/decompress_bytes.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2025-11-22 08:00:00 +0800
committerGravatar Runxi Yu2025-11-22 08:00:00 +0800
commita504524ca695f04692f5a2cf49952ed039a6a348 (patch)
tree4d0ab8463f1bd9be22aab2af7b7d38f88ef24c77 /internal/flatex/decompress_bytes.go
parentbufpool: Improve perf by using buckets of different size classes (diff)
signatureNo signature
bufpool: Return *Buffer
Diffstat (limited to 'internal/flatex/decompress_bytes.go')
-rw-r--r--internal/flatex/decompress_bytes.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/internal/flatex/decompress_bytes.go b/internal/flatex/decompress_bytes.go
index 5e29f82d..ce6d0558 100644
--- a/internal/flatex/decompress_bytes.go
+++ b/internal/flatex/decompress_bytes.go
@@ -25,26 +25,26 @@ var bufferDecompressorPool = sync.Pool{
// Decompress inflates the provided DEFLATE stream and returns the full output
// in a pooled bufpool.Buffer along with the number of consumed bytes from src.
-func Decompress(src []byte) (bufpool.Buffer, int, error) {
+func Decompress(src []byte) (*bufpool.Buffer, int, error) {
return DecompressDictSized(src, nil, 0)
}
// DecompressDict inflates the provided DEFLATE stream using dict as the preset
// dictionary and returns the full output in a pooled bufpool.Buffer. The second
// returned value reports how many bytes of src were consumed.
-func DecompressDict(src []byte, dict []byte) (bufpool.Buffer, int, error) {
+func DecompressDict(src []byte, dict []byte) (*bufpool.Buffer, int, error) {
return DecompressDictSized(src, dict, 0)
}
// DecompressDictSized is like DecompressDict but allows providing an expected
// output size to pre-size the destination buffer and avoid repeated growth.
// A non-positive sizeHint falls back to the default buffer capacity.
-func DecompressDictSized(src []byte, dict []byte, sizeHint int) (bufpool.Buffer, int, error) {
+func DecompressDictSized(src []byte, dict []byte, sizeHint int) (*bufpool.Buffer, int, error) {
d := bufferDecompressorPool.Get().(*bufferDecompressor)
defer bufferDecompressorPool.Put(d)
if err := d.inflater.reset(src, dict); err != nil {
- return bufpool.Buffer{}, 0, err
+ return nil, 0, err
}
out := bufpool.Borrow(sizeHint)
@@ -61,7 +61,7 @@ func DecompressDictSized(src []byte, dict []byte, sizeHint int) (bufpool.Buffer,
return out, d.inflater.pos, nil
}
out.Release()
- return bufpool.Buffer{}, 0, d.inflater.err
+ return nil, 0, d.inflater.err
}
d.inflater.step(&d.inflater)
if d.inflater.err != nil && len(d.inflater.toRead) == 0 {