Skip to content
/ intern Public
forked from josharian/intern

Intern or memoize strings, byte/rune slices, or any other type (experimental)

License

Notifications You must be signed in to change notification settings

CAFxX/intern

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

intern

A small library for best-effort interning and memoization of arbitrary types, with specializations for string, []byte, and []rune.

GoDoc

Compared to the josharian/intern upstream this fork:

  • supports also []rune in addition to string and []byte
  • makes use of generics (as such it requires Go >= 1.18)
  • provides a generic Map[K, V] interner that allows to intern/memoize custom types (see ExampleMap)
  • optionally provide a unsafe-based implementation that is ~25% faster than the regular one and that it is more stable (less likely to cause OOM errors under pathological usage patterns): it can be enabled with the intern_unsafe build tag

For a blog post introducing string interning, see: https://commaok.xyz/post/intern-strings/

License: MIT

About

Intern or memoize strings, byte/rune slices, or any other type (experimental)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%