Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByteAllocator ¶
type ByteAllocator []byte
ByteAllocator provides chunk allocation of []byte, amortizing the overhead of each allocation. Because the underlying storage for the slices is shared, they should share a similar lifetime in order to avoid pinning large amounts of memory unnecessarily. The allocator itself is a []byte where cap() indicates the total amount of memory and len() is the amount already allocated. The size of the buffer to allocate from is grown exponentially when it runs out of room up to a maximum size (chunkAllocMaxSize).
func (ByteAllocator) Alloc ¶
func (a ByteAllocator) Alloc(n int) (ByteAllocator, []byte)
Alloc allocates a new chunk of memory with the specified length.
func (ByteAllocator) Copy ¶
func (a ByteAllocator) Copy(src []byte) (ByteAllocator, []byte)
Copy allocates a new chunk of memory, initializing it from src.