Files
go-simple-graphql/pools.go
T
lukaszraczylo 28eec46f4c General improvements:
Added sharded cache to reduce lock contention
Optimized buffer usage with pre-sized pools
Improved HTTP client with connection pooling and timeouts
Reduced allocations in JSON handling
2025-01-08 11:16:51 +00:00

25 lines
419 B
Go

package gql
import (
"bytes"
"sync"
)
var (
// Pre-sized buffer pool for better performance
bufferPool = sync.Pool{
New: func() interface{} {
// Pre-allocate buffer with 4KB capacity
b := bytes.NewBuffer(make([]byte, 0, 4096))
return b
},
}
// Pre-allocate error maps to reduce allocations
errPairsPool = sync.Pool{
New: func() interface{} {
return make(map[string]interface{}, 1)
},
}
)