what is going to be the impact in terms of performance of allocating a new variable for each iteration of the loop ?
Is the compiler smart enough to only do this when it's needed ?
Is the compiler smart enough to only do this when it's needed ?
func foo(constFunc func(*[100000]int)) {
for a, i := [100000]int{}, 0; i < len(a); i++ {
constFunc(&a)
}
}
in which, the big array a will be duplicated at each step.Performance downgrade is just one problem, the most serious problem is it will break some code, such as https://gotipplay.golang.org/p/srBxORL4bm__b. The code outputs differently with 1.22 and 1.22-.