alloc

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allocator

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

Allocator is simply a container with a big byte-slice inside. It is responsible for keeping header values together instead of having a lot of smaller slices. This decreases a GC pressure (having less pointers), and potentially makes code easier & doing less memory allocations

func NewAllocator

func NewAllocator(initialSpace, maxSpace int) Allocator

func (*Allocator) Append

func (a *Allocator) Append(chars []byte) (ok bool)

Append appends bytes to a buffer. In case space is not enough, trying to allocate a new by appending a fitting part into current buffer, and appending the rest, allowing a slice to grow by its built-in algorithm

func (*Allocator) Clear

func (a *Allocator) Clear()

func (*Allocator) Finish

func (a *Allocator) Finish() []byte

Jump to

Keyboard shortcuts

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