Source File
intern.go
Belonging Package
github.com/josharian/intern
// 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 internimportvar (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}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |