Source File
encode_pool.go
Belonging Package
github.com/francoispqt/gojay
package gojayimport ()var encPool = sync.Pool{New: func() interface{} {return NewEncoder(nil)},}var streamEncPool = sync.Pool{New: func() interface{} {return Stream.NewEncoder(nil)},}func init() {for := 0; < 32; ++ {encPool.Put(NewEncoder(nil))}for := 0; < 32; ++ {streamEncPool.Put(Stream.NewEncoder(nil))}}// NewEncoder returns a new encoder or borrows one from the poolfunc ( io.Writer) *Encoder {return &Encoder{w: }}// BorrowEncoder borrows an Encoder from the pool.func ( io.Writer) *Encoder {:= encPool.Get().(*Encoder).w =.buf = .buf[:0].isPooled = 0.err = nil.hasKeys = false.keys = nilreturn}// Release sends back a Encoder to the pool.func ( *Encoder) () {.isPooled = 1encPool.Put()}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |