MCPcopy Index your code
hub / github.com/codechenx/FastTableViewer / intern

Method intern

buffer.go:24–38  ·  view source on GitHub ↗

intern returns a canonical version of the string, reducing memory usage

(s string)

Source from the content-addressed store, hash-verified

22
23// intern returns a canonical version of the string, reducing memory usage
24func (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)

Callers 3

enableStringInterningMethod · 0.80
internValueMethod · 0.80
TestStringInternerFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestStringInternerFunction · 0.64