Get returns new byte buffer with zero length. The byte buffer may be returned to the pool via Put after the use in order to minimize GC overhead.
()
| 46 | // The byte buffer may be returned to the pool via Put after the use |
| 47 | // in order to minimize GC overhead. |
| 48 | func (p *Pool) Get() *ByteBuffer { |
| 49 | v := p.pool.Get() |
| 50 | if v != nil { |
| 51 | return v.(*ByteBuffer) |
| 52 | } |
| 53 | return &ByteBuffer{ |
| 54 | B: make([]byte, 0, atomic.LoadUint64(&p.defaultSize)), |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | // Put returns byte buffer to the pool. |
| 59 | // |
no outgoing calls