optimized switch compilation

This commit is contained in:
satyr
2010-10-25 06:20:45 +09:00
parent d1094e11a0
commit e146b539f5
2 changed files with 4 additions and 4 deletions

View File

@@ -1674,14 +1674,14 @@
var _i, _j, _len, _len2, _ref2, _ref3, _ref4, _ref5, block, code, cond, conditions, expr, i, idt1, idt2;
idt1 = this.idt(1);
idt2 = o.indent = this.idt(2);
code = this.tab + ("switch (" + (((_ref2 = this.subject) != null ? _ref2.compile(o, LEVEL_PAREN) : undefined) || true) + ") {\n");
code = this.tab + ("switch (" + (((_ref2 = this.subject) != null ? _ref2.compile(o, LEVEL_PAREN) : undefined) || false) + ") {\n");
for (i = 0, _len = this.cases.length; i < _len; i++) {
_ref3 = this.cases[i], conditions = _ref3[0], block = _ref3[1];
_ref4 = flatten([conditions]);
for (_i = 0, _len2 = _ref4.length; _i < _len2; _i++) {
cond = _ref4[_i];
if (!this.subject) {
cond = cond.invert().invert();
cond = cond.invert();
}
code += idt1 + ("case " + (cond.compile(o, LEVEL_PAREN)) + ":\n");
}