MCPcopy Create free account
hub / github.com/unrolled/render / NewSizedBufferPool

Function NewSizedBufferPool

sizedbufferpool.go:26–31  ·  view source on GitHub ↗

NewSizedBufferPool creates a new BufferPool bounded to the given size. size defines the number of buffers to be retained in the pool and alloc sets the initial capacity of new buffers to minimize calls to make(). The value of alloc should seek to provide a buffer that is representative of most data

(size int, alloc int)

Source from the content-addressed store, hash-verified

24// track the capacity of your last N buffers (i.e. using an []int) prior to
25// returning them to the pool as input into calculating a suitable alloc value.
26func NewSizedBufferPool(size int, alloc int) (bp *SizedBufferPool) {
27 return &SizedBufferPool{
28 c: make(chan *bytes.Buffer, size),
29 a: alloc,
30 }
31}
32
33// Get gets a Buffer from the SizedBufferPool, or creates a new one if none are
34// available in the pool. Buffers have a pre-allocated capacity.

Callers 2

prepareOptionsMethod · 0.85

Calls

no outgoing calls

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…