Re: [go-nuts] `for i, v := range` causes allocation

2021-04-12 Thread Luke Wilson
On 4/12/21 11:31 AM, Jan Mercl wrote: I believe no silent allocation and no conversion to a slice of runes occurs. A single instance of variable c, of type rune, exists within the loop. There's no problem with modifying 'c'. A problem exists if the _address_ of 'c' is assumed to point to

Re: [go-nuts] `for i, v := range` causes allocation

2021-04-12 Thread Ian Lance Taylor
On Mon, Apr 12, 2021 at 9:01 AM Luke Wilson wrote: > > I've heard several times from members of the community (on Matrix and > possibly on answers) that a simple iteration like > > const mixed = "\b5Ὂg̀9! ℃ᾭG" > for _, c := range mixed { > ... do something with c (but not write to it) > > will

Re: [go-nuts] `for i, v := range` causes allocation

2021-04-12 Thread Jan Mercl
On Mon, Apr 12, 2021 at 6:01 PM Luke Wilson wrote: > I've heard several times from members of the community (on Matrix and > possibly on answers) that a simple iteration like > > const mixed = "\b5Ὂg̀9! ℃ᾭG" > for _, c := range mixed { > ... do something with c (but not write to it) > > will

[go-nuts] `for i, v := range` causes allocation

2021-04-12 Thread Luke Wilson
I've heard several times from members of the community (on Matrix and possibly on answers) that a simple iteration like const mixed = "\b5Ὂg̀9! ℃ᾭG" for _, c := range mixed { ... do something with c (but not write to it) will actually silently allocate a slice of runes and decode the