bytesbuffer

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool contains logic of reusing byte slices of various size.

func New

func New(min, max int) *Pool

New creates new Pool that reuses slices which size is in logarithmic range [min, max].

Note that it is a shortcut for Custom() constructor with Options provided by pool.WithLogSizeMapping() and pool.WithLogSizeRange(min, max) calls.

func (*Pool) Get

func (p *Pool) Get(c int) *bytes.Buffer

Get returns probably reused slice of bytes with at least capacity of c and exactly len of n.

func (*Pool) Put

func (p *Pool) Put(bf *bytes.Buffer)

Put returns given slice to reuse pool. It does not reuse bytes whose size is not power of two or is out of pool min/max range.

Jump to

Keyboard shortcuts

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