Jason,Your example does not appear to support your claim.A benchmark:package main
import (
"strconv"
"testing"
)
type A struct {
B string
}
func mycode(slice []A) {
slice = slice[1:]
}
func BenchmarkMycode(b *testing.B) {
a := make([]A, 256)
for i := range a {
a[i].B = "B: " + strconv.Itoa(i*cap(a))
}
b.ResetTimer()
for N := 0; N < b.N; N++ {
mycode(a)
}
}
Output:
$ go version
go version go1.14 linux/amd64
$ go test mycode_test.go -bench=. -benchmem
BenchmarkMycode-4 1000000000 0.290 ns/op 0 B/op 0 allocs/opPeter
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/gMF1XdTTlWo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/efc1c5ba-34d0-476f-be3e-7f0c9b84d816%40googlegroups.com.