Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
Which is more efficient, a switch statement or an if else chain?
Which is more efficient, a switch statement or an if else chain?
✍: Guest
The differences, if any, are likely to be slight. The switch statement was designed to be efficiently implementable, though the compiler may choose to use the equivalent of an if/else chain (as opposed to a compact jump table) if the case labels are sparsely distributed.
Do use switch when you can: it's certainly cleaner, and perhaps more efficient (and certainly should never be any less efficient).
2015-02-04, 1167👍, 0💬
Popular Posts:
What is normalization? What are different types of normalization? It is set of rules that have been ...
How To Escape Special Characters in SQL statements? - MySQL FAQs - Introduction to SQL Basics There ...
What is the version information in XML? “version” tag shows which version of XML is used.
How To Get the Minimum or Maximum Value of an Array? - PHP Script Tips - PHP Built-in Functions for ...
What will be printed as the result of the operation below: #define swap(a,b) a=a+b;b=a-b;a=a-b; void...