This section is empty.


This section is empty.


This section is empty.


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.

Source Files