Mar 25, 2021

[Go] memclr for array and slice (not pointer to array)

Reference:
https://github.com/golang/go/issues/5373

Quote:

There should be a fast way to zero memory. When implementing object pools (reusing []byte or []int), for safety the application's pool allocator needs to zero memory before giving it back out to callers.  Currently Go can't do it very quickly.

Ideally, yes.

Rob was talking about this, so I filed a bug.

I'd also want:

for i := range b {

   b[i] = MyStruct{}

}

... to be recognized.


memclr Optimization:

for i := range a {
	a[i] = t0
}

s := a[:]
for i := range s {
	s[i] = t0
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.