diff --git a/image/png_encoder_buf_pool.go b/image/png_encoder_buf_pool.go new file mode 100644 index 0000000..7d3164d --- /dev/null +++ b/image/png_encoder_buf_pool.go @@ -0,0 +1,22 @@ +package util + +import ( + "sync" + "image/png" +) + +type PNGEncoderBufPool struct { + pool sync.Pool +} + +func (p *PNGEncoderBufPool) Get() *png.EncoderBuffer { + v := p.pool.Get() + if v == nil { + return &png.EncoderBuffer{} + } + return v.(*png.EncoderBuffer) + +} +func (p *PNGEncoderBufPool) Put(buf *png.EncoderBuffer) { + p.pool.Put(buf) +}