On Tue, Feb 18, 2020 at 9:47 AM Brian Candler <b.cand...@pobox.com> wrote:
>
> Could you provide a link to where you found this code?  I imagine it was done 
> that way just for demonstrating some features of go, such as slicing and 
> array lookups.
>
> A simpler and faster way again would be to use a map.
> https://play.golang.org/p/ntjhesMsSA9

I don't see how could be map lookup possibly faster than slice
indexing. Have you some measurements to share?

Same applies to using the switch as suggested by Vincent.

In both cases, the branch predictor and or speculative execution in
modern CPUs, can completely mislead measuring small cases.

-- 
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-Uf5Xa_24SYU39mGr07fjufYTti5nCDRRakd4LAMhc8ZA%40mail.gmail.com.

Reply via email to