package foo
import (
"testing"
)
type Foo struct {
H string
A int64
B int64
C int64
}
func BenchmarkClear4(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
testFoo := make([]Foo, 100)
for pb.Next() {
for i := range testFoo {
testFoo[i] = Foo{}
}
}
})
}
For me (go 1.8) the above snippet results in asm that doesn't make use of memclr. On the other hand, when I comment out field C in the struct above then the code does make use of the optimization. Similarly, when I change the first field from string to int64, it also works. Is this expected? If so, is there some documentation for the criteria for the optimization?