mirror of
https://github.com/luxfi/pool.git
synced 2026-09-24 00:24:02 +00:00
Go 1.27.1, and the code it can say more simply
Modules declare go 1.27.1 and the build images follow. go fix applied the modernizers; omitzero is not applied, since it changes what the JSON says. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
// ByteSlicePool provides optimized byte slice pooling
|
||||
// Similar to VictoriaMetrics' approach for reducing allocations
|
||||
var ByteSlicePool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return make([]byte, 0, 1024)
|
||||
},
|
||||
}
|
||||
@@ -31,7 +31,7 @@ func PutByteSlice(b []byte) {
|
||||
// StringPool provides string pooling for common strings
|
||||
// Uses unsafe conversion to avoid allocations
|
||||
var StringPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return ""
|
||||
},
|
||||
}
|
||||
@@ -52,18 +52,18 @@ func PutString(s string) {
|
||||
// InterfaceSlicePool provides pooling for interface slices
|
||||
// Useful for JSON marshaling/unmarshaling
|
||||
var InterfaceSlicePool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return make([]interface{}, 0, 16)
|
||||
New: func() any {
|
||||
return make([]any, 0, 16)
|
||||
},
|
||||
}
|
||||
|
||||
// GetInterfaceSlice gets an interface slice from the pool
|
||||
func GetInterfaceSlice() []interface{} {
|
||||
return InterfaceSlicePool.Get().([]interface{})
|
||||
func GetInterfaceSlice() []any {
|
||||
return InterfaceSlicePool.Get().([]any)
|
||||
}
|
||||
|
||||
// PutInterfaceSlice returns an interface slice to the pool
|
||||
func PutInterfaceSlice(s []interface{}) {
|
||||
func PutInterfaceSlice(s []any) {
|
||||
if cap(s) > 1024 { // Don't pool large slices
|
||||
return
|
||||
}
|
||||
@@ -73,18 +73,18 @@ func PutInterfaceSlice(s []interface{}) {
|
||||
// MapPool provides pooling for maps
|
||||
// Specialized for common map types
|
||||
var MapPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return make(map[string]interface{}, 16)
|
||||
New: func() any {
|
||||
return make(map[string]any, 16)
|
||||
},
|
||||
}
|
||||
|
||||
// GetMap gets a map from the pool
|
||||
func GetMap() map[string]interface{} {
|
||||
return MapPool.Get().(map[string]interface{})
|
||||
func GetMap() map[string]any {
|
||||
return MapPool.Get().(map[string]any)
|
||||
}
|
||||
|
||||
// PutMap returns a map to the pool
|
||||
func PutMap(m map[string]interface{}) {
|
||||
func PutMap(m map[string]any) {
|
||||
if len(m) > 1024 { // Don't pool large maps
|
||||
return
|
||||
}
|
||||
@@ -137,7 +137,7 @@ func (b *FastBuffer) Free() {
|
||||
|
||||
// GetFastBuffer gets a FastBuffer from the pool
|
||||
var fastBufferPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return NewFastBuffer()
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user