mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
slightly optimizing return values of AssignNodes. Issue #539
This commit is contained in:
@@ -17,12 +17,11 @@
|
||||
action = _a[0];
|
||||
description = _a[1];
|
||||
}
|
||||
tasks[name] = {
|
||||
return (tasks[name] = {
|
||||
name: name,
|
||||
description: description,
|
||||
action: action
|
||||
};
|
||||
return tasks[name];
|
||||
});
|
||||
},
|
||||
option: function(letter, flag, description) {
|
||||
return switches.push([letter, flag, description]);
|
||||
|
||||
@@ -51,8 +51,7 @@
|
||||
},
|
||||
setInput: function(tokens) {
|
||||
this.tokens = tokens;
|
||||
this.pos = 0;
|
||||
return this.pos;
|
||||
return (this.pos = 0);
|
||||
},
|
||||
upcomingInput: function() {
|
||||
return "";
|
||||
|
||||
@@ -195,8 +195,7 @@
|
||||
options.compile = options.compile || !!o.output;
|
||||
options.run = !(o.compile || o.print || o.lint);
|
||||
options.print = !!(o.print || (o.eval || o.stdio && o.compile));
|
||||
sources = options.arguments;
|
||||
return sources;
|
||||
return (sources = options.arguments);
|
||||
};
|
||||
compileOptions = function(source) {
|
||||
var o;
|
||||
|
||||
@@ -399,8 +399,7 @@
|
||||
} else if (_d === ')') {
|
||||
tok[0] = 'PARAM_END';
|
||||
} else if (_d === '(' || _d === 'CALL_START') {
|
||||
tok[0] = 'PARAM_START';
|
||||
return tok[0];
|
||||
return (tok[0] = 'PARAM_START');
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -555,8 +554,7 @@
|
||||
return null;
|
||||
}
|
||||
if (typeof newTag !== "undefined" && newTag !== null) {
|
||||
tok[0] = newTag;
|
||||
return tok[0];
|
||||
return (tok[0] = newTag);
|
||||
}
|
||||
return tok[0];
|
||||
};
|
||||
@@ -566,8 +564,7 @@
|
||||
return null;
|
||||
}
|
||||
if (typeof val !== "undefined" && val !== null) {
|
||||
tok[1] = val;
|
||||
return tok[1];
|
||||
return (tok[1] = val);
|
||||
}
|
||||
return tok[1];
|
||||
};
|
||||
|
||||
14
lib/nodes.js
14
lib/nodes.js
@@ -394,8 +394,7 @@
|
||||
part = prop.compile(o);
|
||||
baseline += part;
|
||||
complete += part;
|
||||
this.last = part;
|
||||
return this.last;
|
||||
return (this.last = part);
|
||||
}
|
||||
}).call(this);
|
||||
}
|
||||
@@ -447,7 +446,7 @@
|
||||
CallNode.prototype.superReference = function(o) {
|
||||
var meth, methname;
|
||||
methname = o.scope.method.name;
|
||||
meth = (function() {
|
||||
return (meth = (function() {
|
||||
if (o.scope.method.proto) {
|
||||
return "" + (o.scope.method.proto) + ".__superClass__." + methname;
|
||||
} else if (methname) {
|
||||
@@ -455,8 +454,7 @@
|
||||
} else {
|
||||
throw new Error("cannot call super on an anonymous function.");
|
||||
}
|
||||
})();
|
||||
return meth;
|
||||
})());
|
||||
};
|
||||
CallNode.prototype.compileNode = function(o) {
|
||||
var _b, _c, _d, _e, _f, _g, _h, arg, args, compilation;
|
||||
@@ -836,7 +834,11 @@
|
||||
return this.variable instanceof ValueNode;
|
||||
};
|
||||
AssignNode.prototype.makeReturn = function() {
|
||||
return new Expressions([this, new ReturnNode(this.variable)]);
|
||||
if (this.isStatement()) {
|
||||
return new Expressions([this, new ReturnNode(this.variable)]);
|
||||
} else {
|
||||
return AssignNode.__superClass__.makeReturn.call(this);
|
||||
}
|
||||
};
|
||||
AssignNode.prototype.isStatement = function() {
|
||||
return this.isValue() && (this.variable.isArray() || this.variable.isObject());
|
||||
|
||||
@@ -41,8 +41,7 @@
|
||||
return false;
|
||||
};
|
||||
Scope.prototype.parameter = function(name) {
|
||||
this.variables[name] = 'param';
|
||||
return this.variables[name];
|
||||
return (this.variables[name] = 'param');
|
||||
};
|
||||
Scope.prototype.check = function(name) {
|
||||
if (this.variables.hasOwnProperty(name)) {
|
||||
@@ -60,11 +59,10 @@
|
||||
return this.tempVar;
|
||||
};
|
||||
Scope.prototype.assign = function(name, value) {
|
||||
this.variables[name] = {
|
||||
return (this.variables[name] = {
|
||||
value: value,
|
||||
assigned: true
|
||||
};
|
||||
return this.variables[name];
|
||||
});
|
||||
};
|
||||
Scope.prototype.hasDeclarations = function(body) {
|
||||
return body === this.expressions && this.any(function(k, val) {
|
||||
|
||||
@@ -758,7 +758,10 @@ exports.AssignNode: class AssignNode extends BaseNode
|
||||
@variable instanceof ValueNode
|
||||
|
||||
makeReturn: ->
|
||||
return new Expressions [this, new ReturnNode(@variable)]
|
||||
if @isStatement()
|
||||
return new Expressions [this, new ReturnNode(@variable)]
|
||||
else
|
||||
super()
|
||||
|
||||
isStatement: ->
|
||||
@isValue() and (@variable.isArray() or @variable.isObject())
|
||||
|
||||
Reference in New Issue
Block a user