Status: Accepted
Owner: ----
Labels: Type-Bug Priority-Medium
New issue 2684 by [email protected]: switch over string literals is
considerably slower than a sequence of ifs with strict equality
http://code.google.com/p/v8/issues/detail?id=2684
Compare speed:
if (x === "a") {
/* code for a */
} else if (x === "b") {
/* code for b */
} else if (x === "c") {
/* code for c */
}
with
switch (x) {
case "a"; /* code for a */ break;
case "b"; /* code for b */ break;
case "c"; /* code for c */ break;
}
See http://jsperf.com/switch-if-else/30
The reason: comparisons in the if-variant are specialized to become pointer
comparisons, in switch-variant they are always emitted through COMPARE_IC.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.