aboutsummaryrefslogtreecommitdiff
path: root/internal/flatex/slice_inflate.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2025-11-25 08:00:00 +0800
committerGravatar Runxi Yu2025-11-25 08:00:00 +0800
commit94a6325ee646be4a06ca0646fcd797b2a9c74581 (patch)
tree1b9dd5018a7c5871e9f8204b7b6899006ce1d4c7 /internal/flatex/slice_inflate.go
parentflatex: Remove unused cruft (diff)
signatureNo signature
flatex: Restructure a little
Diffstat (limited to 'internal/flatex/slice_inflate.go')
-rw-r--r--internal/flatex/slice_inflate.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/internal/flatex/slice_inflate.go b/internal/flatex/slice_inflate.go
index 3e07e744..f9120143 100644
--- a/internal/flatex/slice_inflate.go
+++ b/internal/flatex/slice_inflate.go
@@ -3,6 +3,7 @@ package flatex
import (
"io"
"math/bits"
+ "sync"
)
// sliceInflater is a specialized DEFLATE decoder that reads directly from an
@@ -33,6 +34,16 @@ type sliceInflater struct {
copyDist int
}
+var sliceInflaterPool = sync.Pool{
+ New: func() any {
+ fixedHuffmanDecoderInit()
+ return &sliceInflater{
+ bits: new([maxNumLit + maxNumDist]int),
+ codebits: new([numCodes]int),
+ }
+ },
+}
+
func (f *sliceInflater) reset(src []byte) error {
bits := f.bits
codebits := f.codebits