VictoriaMetrics/lib/logstorage/stringbucket.go

30 lines
402 B
Go

package logstorage
import (
"sync"
)
type stringBucket struct {
a []string
}
func (sb *stringBucket) reset() {
clear(sb.a)
sb.a = sb.a[:0]
}
func getStringBucket() *stringBucket {
v := stringBucketPool.Get()
if v == nil {
return &stringBucket{}
}
return v.(*stringBucket)
}
func putStringBucket(sb *stringBucket) {
sb.reset()
stringBucketPool.Put(sb)
}
var stringBucketPool sync.Pool