One ranges a copy of the array, the other does not:
https://play.golang.org/p/Z3InmyFqQN3

On Fri, Aug 16, 2019, 19:11 Vadim Maximov <vadim.maxi...@gmail.com> wrote:

> Hi, all!
>
> Is *for.*..*range* over an address/reference of  an array faster than
> regular *for...range*? For instance:
>
> arr :=[...]int{1,2,3}
> for _,v := range &arr{
>    fmt.Println(v)
> }
>
> I heard that it  is slightly faster for huge arrays, but why is it so? And
> is it actually true (or makes sense)?
>
> --
> 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/33c85347-6b48-4e74-9718-15d5b7317f93%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/33c85347-6b48-4e74-9718-15d5b7317f93%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAA40n-Us8bVh%2BuBpV4ku3qJkitK58kjMgLwuu6K8JbunJCYj7A%40mail.gmail.com.

Reply via email to