Speed: A switch statement might prove to be faster than ifs provided number of cases are good. If there are only few cases, it might not effect the speed in any case. Prefer switch if the number of cases are more than 5 otherwise, you may use if-else too. If a switch contains more than five items, it’s implemented using a lookup table or a hash list. This means that all items get the same access time, compared to a list of if:s where the last item takes much more time to reach as it has to evaluate every previous condition first.
https://www.geeksforgeeks.org/switch-vs-else/ [ Full content available at: https://github.com/apache/incubator-dubbo/pull/2399 ] This message was relayed via gitbox.apache.org for [email protected]
