This commit is contained in:
Aliaksandr Valialkin 2024-04-29 07:44:23 +02:00
parent 65dfdda14b
commit a62b0ab12b
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
2 changed files with 29 additions and 24 deletions

View file

@ -67,30 +67,6 @@ func (fs *streamFilter) apply(bs *blockSearch, bm *bitmap) {
} }
} }
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
func getTokensSkipLast(s string) []string { func getTokensSkipLast(s string) []string {
for { for {
r, runeSize := utf8.DecodeLastRuneInString(s) r, runeSize := utf8.DecodeLastRuneInString(s)

View file

@ -0,0 +1,29 @@
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