NewResultPool creates a pool for reusing IteratorResults. New items are created with the given default capacity. Using different pools is helpful to keep items of similar sizes together which reduces slice allocations.
(defaultCapacity int)
| 17 | // with the given default capacity. Using different pools is helpful to keep |
| 18 | // items of similar sizes together which reduces slice allocations. |
| 19 | func NewResultPool(defaultCapacity int) *ResultPool { |
| 20 | return &ResultPool{ |
| 21 | pool: &sync.Pool{}, |
| 22 | cap: defaultCapacity, |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | func (p *ResultPool) Get() *IteratorResult { |
| 27 | if x := p.pool.Get(); x != nil { |
no outgoing calls