byteslicepool

package
v0.13.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2024 License: Apache-2.0 Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteSlicePool

type ByteSlicePool struct {
	MinCap int
	// contains filtered or unexported fields
}

ByteSlicePool is a wrapper around sync.Pool to get []byte objects with a given capacity.

func NewByteSlicePool

func NewByteSlicePool(minCap int) *ByteSlicePool

NewByteSlicePool returns a new ByteSlicePool object.

func (ByteSlicePool) Get

func (sp ByteSlicePool) Get(capacity int) []byte

Get a slice from the pool. The capacity parameter is used only if we need to allocate a new byte slice; there's no guarantee a slice retrieved from the pool will have enough capacity for that.

func (ByteSlicePool) Put

func (sp ByteSlicePool) Put(bs []byte)

Put a slice back in the pool.

func (ByteSlicePool) Resize

func (sp ByteSlicePool) Resize(orig []byte, size int) []byte

Resize a byte slice, making sure that it has enough capacity for a given size.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL