mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-20 23:46:23 +01:00
32 lines
500 B
Go
32 lines
500 B
Go
package logstorage
|
|
|
|
import (
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil"
|
|
)
|
|
|
|
type arena struct {
|
|
b []byte
|
|
}
|
|
|
|
func (a *arena) reset() {
|
|
a.b = a.b[:0]
|
|
}
|
|
|
|
func (a *arena) copyBytes(b []byte) []byte {
|
|
ab := a.b
|
|
abLen := len(ab)
|
|
ab = append(ab, b...)
|
|
result := ab[abLen:]
|
|
a.b = ab
|
|
return result
|
|
}
|
|
|
|
func (a *arena) newBytes(size int) []byte {
|
|
ab := a.b
|
|
abLen := len(ab)
|
|
ab = bytesutil.ResizeWithCopyMayOverallocate(ab, abLen+size)
|
|
result := ab[abLen:]
|
|
a.b = ab
|
|
return result
|
|
}
|