Thanks to visit codestin.com
Credit goes to pkg.go.dev

pbuffer

package
v1.6.7 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: Apache-2.0, MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPool = New(65536)

DefaultPool is used by pacakge level functions.

Functions

func Get

func Get(c int) *bytes.Buffer

Get returns probably reused *bytes.Buffer of bytes with at least capacity of c Get is a wrapper around DefaultPool.Get().

func Put

func Put(p *bytes.Buffer)

Put returns given *bytes.Buffer to reuse pool. Put is a wrapper around DefaultPool.Put().

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(max int) *Pool

New creates new Pool that reuses slices which size

func (*Pool) Get

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

Get returns probably reused *bytes.Buffer of bytes with at least capacity of c.

func (*Pool) Put

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

Put returns given *bytes.Buffer 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