mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-04-11 03:00:13 -04:00
optimized switch compilation
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user