Add array recycling safety (#19103)

Nil entries when recycling arrays.
This commit is contained in:
Klaus Post
2024-02-21 12:27:35 -08:00
committed by GitHub
parent 22aa16ab12
commit 92180bc793
3 changed files with 24 additions and 14 deletions

View File

@@ -595,8 +595,10 @@ func (p *ArrayOf[T]) newA(sz uint32) []T {
}
func (p *ArrayOf[T]) putA(v []T) {
for _, t := range v {
var zero T // nil
for i, t := range v {
p.ePool.Put(t)
v[i] = zero
}
if v != nil {
v = v[:0]