mirror of
https://github.com/lukaszraczylo/go-simple-graphql.git
synced 2026-10-12 00:45:31 +00:00
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
25 lines
419 B
Go
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)
|
|
},
|
|
}
|
|
)
|