Re: [go-nuts] Re: why would slice = slice[1:] allocate

2020-03-01 Thread Ian Lance Taylor
On Sun, Mar 1, 2020 at 5:56 AM Jason E. Aten wrote: > > escape analysis is eliminating the allocation in the simplification. in > reality the slice is stored in a persistent struct. Can you show us a complete example program? It's possible that the allocation is getting attributed to the wrong

Re: [go-nuts] Re: why would slice = slice[1:] allocate

2020-03-01 Thread Jason E. Aten
escape analysis is eliminating the allocation in the simplification. in reality the slice is stored in a persistent struct. On Sun, Mar 1, 2020 at 8:50 AM wrote: > Jason, > > Your example does not appear to support your claim. > > A benchmark: > > package main > > import ( > "strconv" >

[go-nuts] Re: why would slice = slice[1:] allocate

2020-03-01 Thread so . peter . 05
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 {