// Package intern interns strings. // Interning is best effort only. // Interned strings may be removed automatically // at any time without notification. // All functions may be called concurrently // with themselves and each other.
package intern import var ( pool sync.Pool = sync.Pool{ New: func() interface{} { return make(map[string]string) }, } ) // String returns s, interned. func ( string) string { := pool.Get().(map[string]string) , := [] if { pool.Put() return } [] = pool.Put() return } // Bytes returns b converted to a string, interned. func ( []byte) string { := pool.Get().(map[string]string) , := [string()] if { pool.Put() return } := string() [] = pool.Put() return }