Help us shape the future of Go! Take the 2026 Go Developer Survey

bytespool

package module
v0.0.0-...-1090b6d Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: MIT Imports: 1 Imported by: 0

README

bytespool-go

bytespool provides a sync.Pool with *[]byte to reduce memory allocation.

go test -v -benchmem -run="^$" github.com/detailyang/bytespool-go -bench "^Benchmark"
goos: darwin
goarch: amd64
pkg: github.com/detailyang/bytespool-go
BenchmarkPool-8   	50474030	        22.2 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	github.com/detailyang/bytespool-go	1.154s

Documentation

Overview

Package bytespool provides a sync.Pool with *[]byte to reduce memory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcquireBytes

func AcquireBytes() *[]byte

AcquireBytes acquires the []byte from pool.

func ReleaseBytes

func ReleaseBytes(b *[]byte)

ReleaseBytes releases the []byte to pool.

Types

type Pool

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

Pool wraps the sync.Pool with *[]byte.

func NewPool

func NewPool() *Pool

NewPool creates a pool.

func (*Pool) Acquire

func (p *Pool) Acquire() *[]byte

Acquire releases the []byte from pool.

func (*Pool) Release

func (p *Pool) Release(b *[]byte)

Release releases the []byte to pool.

Jump to

Keyboard shortcuts

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