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 different variables in
each cycle. That's not the case.

And Ian Lance Taylor:

There are different Go compilers, but I'm not aware of any compiler
that implements range over a string by first converting the string to
a slice of runes.  The default Go compiler implements this by calling
runtime.decoderune in a loop to fetch each new rune.  You can see that
code athttps://golang.org/src/runtime/utf8.go#L51.  There won't be
any additional allocation in this statement.

Sweet, I am very excited to hear this. Thanks Ian, and Jan. I'll let people know.

--
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/4432d4a3-1722-0efc-d414-33f76c0fd3d3%40gmail.com.

Reply via email to