digester

package
v1.41.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Digester

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

Digester creates a null-delimited byte slice from a series of strings. It's an efficient way to create map keys.

This helps because (1) appending to a string allocates and (2) converting a byte slice to a string allocates, but (3) the Go compiler optimizes away byte-to-string conversions in map lookups. Using this type to build up a key and doing map lookups with myMap[string(d.digest())] is fast and zero-allocation.

func New

func New() *Digester

New creates a new Digester. For optimal performance, be sure to call "Free" on each digester.

func (*Digester) Add

func (d *Digester) Add(s string)

Add adds a string to the digester slice.

func (*Digester) Digest

func (d *Digester) Digest() []byte

Digest returns a map key for the digester.

func (*Digester) Free

func (d *Digester) Free()

Free is called to indicate that the digester can be returned to the pool to be used in another context.

Jump to

Keyboard shortcuts

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