1 // stringpool provides a pool of string pointers, ensuring that each string is
2 // stored only once in memory. This is useful for queries that have many
3 // results, as the amount of source packages is limited. So, as soon as
4 // len(results) > len(sourcepackages), you save memory using a stringpool.
11 type StringPool
struct {
13 strings
map[string]*string
16 func NewStringPool() *StringPool
{
18 strings
: make(map[string]*string)}
21 func (pool
*StringPool
) Get(s
string) *string {
22 // Check if the entry is already in the pool with a slightly cheaper
25 stored
, ok
:= pool
.strings
[s
]
33 stored
, ok
= pool
.strings
[s
]