Closed GoogleCodeExporter closed 9 years ago
We generally prioritize optimizations that decrease the compiled size, and
leave the rest to the JS engines.
Out of curiosity, what's better about the branch table if 7 is after 6? I'd
think that it doesn't matter.
Original comment by dim...@google.com
on 9 Jan 2014 at 5:12
because JS engine generates better branch table according to switch statements.
switch 1:
switch(a)
{
case ,
case ,
case ,
case 500:
case 501:
case ,
case ,
}
second switch:
switch(a)
{
case ,
case ,
case ,
case 500:
case 502:
case ,
case ,
}
in switch 1 Js engines generates effective codes.
but in second switch JS/c#/java engines generates 2 switch statements or
generates extra codes for handling case 501.
----------------------------------
another example:
switch(X)
{
case 86:... break;
case 24:... break;
case 38:... break;
case 91:... break;
}
do you think compiler generate switch statements ? answer is no.
many compilers generates if statements for switch(X)
--------------------------------------------
consequently, case index order is the most important in switch statements.
Original comment by beyaz1...@gmail.com
on 10 Jan 2014 at 4:31
if this is worthwhile, then v8 should just do it on its own. I see no good
reason why this should live in closure-compiler over v8.
Original comment by Nicholas.J.Santos
on 11 Jan 2014 at 11:08
Original issue reported on code.google.com by
beyaz1...@gmail.com
on 9 Jan 2014 at 3:31