Skip to content

Commit

Permalink
chore: sync.Pool contains sync.noCopy
Browse files Browse the repository at this point in the history
Signed-off-by: Bo-Yi Wu <[email protected]>
  • Loading branch information
appleboy committed Dec 12, 2021
1 parent d34904d commit 3d908a0
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ type gzipHandler struct {
}

func newGzipHandler(level int, options ...Option) *gzipHandler {
var gzPool sync.Pool
gzPool.New = func() interface{} {
gz, err := gzip.NewWriterLevel(ioutil.Discard, level)
if err != nil {
panic(err)
}
return gz
}
handler := &gzipHandler{
Options: DefaultOptions,
gzPool: gzPool,
gzPool: sync.Pool{
New: func() interface{} {
gz, err := gzip.NewWriterLevel(ioutil.Discard, level)
if err != nil {
panic(err)
}
return gz
},
},
}
for _, setter := range options {
setter(handler.Options)
Expand Down

0 comments on commit 3d908a0

Please sign in to comment.