bufpool

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package bufpool pools byte slices by power-of-two capacity, so a buffer that grew for one large message serves the next of its size instead of being dropped, and never sits in a pool meant for small ones.

Index

Constants

View Source
const (
	// MinBits is the smallest class, 1 KiB; smaller requests get it.
	MinBits = 10
	// MaxBits is the largest class, 64 MiB; larger buffers are not pooled.
	MaxBits = 26
)

Variables

This section is empty.

Functions

func Get

func Get(n int) []byte

Get returns a slice of length 0 and capacity at least n, a power of two when pooled. Contents are whatever the previous holder left.

func Put

func Put(b []byte)

Put returns b to the class of its capacity. A capacity that is not a power of two in range did not come from Get and is left to the GC.

Types

This section is empty.

Jump to

Keyboard shortcuts

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