digester

package
v1.27.2 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2018 License: MIT Imports: 1 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

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