23 lines
332 B
Go
23 lines
332 B
Go
package image
|
|
|
|
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)
|
|
}
|