diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-11-21 18:05:56 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-11-21 18:05:56 -0800 |
commit | daa28da286655690a392958f604c3aeef4acd841 (patch) | |
tree | 21dac68592c93176186348cc511033b36aea2022 /src/jsifier.js | |
parent | 290f0e8634c5c84f59174de9036538afa1fb74f8 (diff) |
some unused code possibilities regarding switch
Diffstat (limited to 'src/jsifier.js')
-rw-r--r-- | src/jsifier.js | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index b7d7a6a6..fb086e29 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -524,13 +524,24 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) { first = false; }); } else { - // TODO: Find out cases where the final if is not needed - where we know we must be in a specific label at that point - block.entryLabels.forEach(function(entryLabel) { - ret += indent + multipleIdent + (first ? '' : 'else ') + 'if (__label__ == ' + getLabelId(entryLabel.ident) + ') {\n'; - ret += walkBlock(entryLabel.block, indent + ' ' + multipleIdent); + // TODO: Find out cases where the final if/case is not needed - where we know we must be in a specific label at that point + var SWITCH_IN_MULTIPLE = 0; // This appears to never be worth it, for no amount of labels + if (SWITCH_IN_MULTIPLE && block.entryLabels.length >= 2) { + ret += indent + multipleIdent + 'switch(__label__) {\n'; + block.entryLabels.forEach(function(entryLabel) { + ret += indent + multipleIdent + ' case ' + getLabelId(entryLabel.ident) + ': {\n'; + ret += walkBlock(entryLabel.block, indent + ' ' + multipleIdent); + ret += indent + multipleIdent + ' } break;\n'; + }); ret += indent + multipleIdent + '}\n'; - first = false; - }); + } else { + block.entryLabels.forEach(function(entryLabel) { + ret += indent + multipleIdent + (first ? '' : 'else ') + 'if (__label__ == ' + getLabelId(entryLabel.ident) + ') {\n'; + ret += walkBlock(entryLabel.block, indent + ' ' + multipleIdent); + ret += indent + multipleIdent + '}\n'; + first = false; + }); + } } if (!block.loopless) { ret += indent + '} while(0);\n'; @@ -794,6 +805,7 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) { } }); makeFuncLineActor('switch', function(item) { + // TODO: Find a case where switch is important, and benchmark that. var SWITCH_IN_SWITCH = 1; var phiSets = calcPhiSets(item); var ret = ''; var first = true; |