(s string, shouldCopy bool)
| 39 | } |
| 40 | |
| 41 | func (p *InternStringPool) intern(s string, shouldCopy bool) string { |
| 42 | z, ok := p.get(s) |
| 43 | if ok { |
| 44 | return z |
| 45 | } |
| 46 | |
| 47 | p.mutex.Lock() |
| 48 | |
| 49 | z, ok = p.pool[s] |
| 50 | if !ok { |
| 51 | if shouldCopy { |
| 52 | s = string([]byte(s)) |
| 53 | } |
| 54 | p.pool[s] = s |
| 55 | z = s |
| 56 | } |
| 57 | |
| 58 | p.mutex.Unlock() |
| 59 | |
| 60 | return z |
| 61 | } |
| 62 | |
| 63 | func (p *InternStringPool) Intern(s string) string { |
| 64 | return p.intern(s, false) |
no test coverage detected