Documentation ¶
Overview ¶
Package bytes implements functions for the manipulation of byte slices.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
BufferPool is a pool implementation of bytes.Buffer. This allows to reuse buffers, which means less allocations.
func NewBufferPool ¶
func NewBufferPool(n, max int) *BufferPool
NewBufferPool creates a pool that will hold up to n buffers. Any buffer will have up to max bytes.
func (*BufferPool) Add ¶
func (bp *BufferPool) Add(buf *bytes.Buffer)
Add appends the given buffer to the pool. If buf is nil or has more than bp.max bytes, a new buffer will be used.
func (*BufferPool) Clear ¶
func (bp *BufferPool) Clear()
Clear discards all the buffers in then pool.
func (*BufferPool) Fill ¶
func (bp *BufferPool) Fill()
Fill fills the pool up to its available capacity.
func (*BufferPool) Get ¶
func (bp *BufferPool) Get() (buf *bytes.Buffer)
Get returns a buffer from the pool. If there are no buffers in the pool a new one with bp.max bytes will be returned.
func (*BufferPool) Len ¶
func (bp *BufferPool) Len() int
Len returns the amount of buffers in the pool.