-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Open
Labels
SuggestedIssues that may be good for new contributors looking for work to do.Issues that may be good for new contributors looking for work to do.
Milestone
Description
What does 'go version' print? go version go1.3 linux/amd64 What steps reproduce the problem? Using the 2-return 'range' over a slice of structs will copy each struct, even if the struct is provably not modified in the loop. This is a premature pessimization that the compiler could and should eliminate. Ideally the spec would guarantee this optimization (a la RVO in C++) so people could count on it and maybe even warn when it is not true. The for-each construct is much nicer to read and write, but this behavior sort of makes it a non-starter for large data. This is discussed in many places on the web, with the general recommendation of "just iterate on index". This is unfortunate for the language. Alternatively: some syntax to say explicitly "iterate by reference" or by pointer. Ian asked me to file this issue.
Metadata
Metadata
Assignees
Labels
SuggestedIssues that may be good for new contributors looking for work to do.Issues that may be good for new contributors looking for work to do.