Suppose myPtr is a pointer and I write code like this:

for _, v := range values {
fmt.Printf("%v %v\n", *myPtr, v)
}

Will the Go compiler optimize the pointer dereference so it doesn't happen
in every loop iteration? If not, is it common practice to do that outside
the loop like this?

myValue := *myPtr
for _, v := range values {
fmt.Printf("%v %v\n", myValue, v)
}

-- 
R. Mark Volkmann
Object Computing, Inc.

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to