package intern

import "github.com/pkg/diff/intern"

Package intern provides string interning.

Unlike much string interning, the routines in this package return *string instead of string. This enables extremely cheap (compare only a pointer) comparisons of any strings interned by this package. Since diff algorithms involve many string comparisons, this often ends up paying for the cost of the interning. Also, in the typical case, diffs involve lots of repeated lines (most of the file contents are typically unchanged, so any give line appears at least twice), so string interning saves memory.

Index

Types

type Strings

type Strings map[string]*string

func (Strings) FromBytes

func (m Strings) FromBytes(b []byte) *string

Source Files

intern.go

Version
v0.0.0-20241224192749-4e6772a4315c (latest)
Published
Dec 24, 2024
Platform
windows/amd64
Last checked
3 hours ago

Tools for package owners.