Hi,
I've seen in many places in go source code re-declaring a variable with the
same name.
e.g:
for i < j {
h := ...
}
Instead of
var h int
for i < j {
h = ...
}
So I did a benchmark to check the differences. I didn't find any
performance related differences, but in terms of Stack Memory in use, the
second approach is better than the first one.
Not sure if the way is in standard library is by intention or something
that should be ignored.
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/769ef260-07be-4556-94d5-989523cb02efn%40googlegroups.com.