With 100 constants: Stringer-4 4.96ns ± 0%
StringerWithSwitch-4 4.99ns ± 1% StringerWithMap-4 30.40ns ± 0% The gap between the switch and the current implement is much smaller. I guess it is due to the number of JMP instructions the code has to go through. It confirms that the results before was accurate. I guess if I increase the number of constant, the current implementation will become faster. However, in real code, I guess we will have that many constants, so it does not make really sense to increase the number. It does not explain why this choice of design^^ The only thing I can see is the binary size... it is slightly bigger with the switch and 100 constants. Le mardi 18 février 2020 14:24:55 UTC+4, pierr...@gmail.com a écrit : > > > I did not add it since it was not the original question ^^ >> But why can't we have the check and a switch? >> >> > Definitely can. Just didnt see it. My response was somewhat tangential to > your question, sry. > -- 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/9fa488e0-73ae-49fc-9a01-f60f7ebc6cfb%40googlegroups.com.