On Tuesday, June 1, 2021 at 10:48:22 AM UTC-4 Jan Mercl wrote:
> On Tue, Jun 1, 2021 at 4:40 PM tapi...@gmail.com <tapi...@gmail.com> > wrote: > > > The following is a tip to get an array pointer but avoid the array > escaping. > > I don't think so. The pointer to the local array 't', stored in 'y' > never leaves the function, so there's no need for 't' to escape. See > the previous post. > But isn't the same situation for 'x'? > > > > package main > > > > const N = 1<<13 > > var i = N-1 > > > > func main() { > > var x = &[N]int{} // escapes to heap > > println(x[i]) > > var t [N]int // not escape > > var y = &t > > println(y[i]) > > } > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/1069b0d6-4c50-4d80-9f2d-bc763059d7ecn%40googlegroups.com.