mirror of
https://github.com/prymitive/karma
synced 2026-05-09 03:36:44 +00:00
17 lines
238 B
Go
17 lines
238 B
Go
package intern
|
|
|
|
type StringInterner map[string]string
|
|
|
|
func New() StringInterner {
|
|
return StringInterner{}
|
|
}
|
|
|
|
func (si StringInterner) Intern(s string) string {
|
|
interned, ok := si[s]
|
|
if ok {
|
|
return interned
|
|
}
|
|
si[s] = s
|
|
return s
|
|
}
|