amuz.es/src/infra/goutils@v0.1.3/image/png_encoder_buf_pool.go (about) 1 package image 2 3 import ( 4 "sync" 5 "image/png" 6 ) 7 8 type PNGEncoderBufPool struct { 9 pool sync.Pool 10 } 11 12 func (p *PNGEncoderBufPool) Get() *png.EncoderBuffer { 13 v := p.pool.Get() 14 if v == nil { 15 return &png.EncoderBuffer{} 16 } 17 return v.(*png.EncoderBuffer) 18 19 } 20 func (p *PNGEncoderBufPool) Put(buf *png.EncoderBuffer) { 21 p.pool.Put(buf) 22 }