intern returns a canonical version of the string, reducing memory usage
(s string)
| 22 | |
| 23 | // intern returns a canonical version of the string, reducing memory usage |
| 24 | func (si *stringInterner) intern(s string) string { |
| 25 | // Quick path for empty strings |
| 26 | if s == "" { |
| 27 | return s |
| 28 | } |
| 29 | |
| 30 | // Try to load existing string |
| 31 | if existing, ok := si.pool.Load(s); ok { |
| 32 | return existing.(string) |
| 33 | } |
| 34 | |
| 35 | // Store and return the string |
| 36 | si.pool.Store(s, s) |
| 37 | return s |
| 38 | } |
| 39 | |
| 40 | // shouldInternColumn determines if a column should use string interning |
| 41 | // based on its cardinality (ratio of unique values to total values) |
no outgoing calls