Skip to content

Commit

Permalink
Add global data pool
Browse files Browse the repository at this point in the history
  • Loading branch information
viciious committed Nov 2, 2023
1 parent 31cd9ea commit 7d3d2a8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pack_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,15 @@ func (pool *packDataPool) Put(data *packData) *packData {
msgp.CopyToJSON(&buf, bytes.NewReader(o))
key := buf.String()

fmt.Println(key, string(o))
fmt.Println("json", key)
fmt.Println("key", string(o))

pool.Lock()
defer pool.Unlock()

if pool.pool == nil {
pool.pool = make(map[string]*packData)
}
if odata, ok := pool.pool[key]; ok {
return odata
}
Expand Down

0 comments on commit 7d3d2a8

Please sign in to comment.