📜  if else 或 switch case 哪个更快 - 无论代码示例

📅  最后修改于: 2022-03-11 14:57:24.080000             🧑  作者: Mango

代码示例1
the switch statement is faster in most cases when compared to if-else , but significantly faster only when the number of conditions is large. The primary difference in performance between the two is that the incremental cost of an additional condition is larger for if-else than it is for switch .