Avoid unnecessary +0 in transform-es2015-parameters (#4738)

This commit is contained in:
Brian Ng
2016-10-17 10:09:55 -05:00
committed by Daniel Tschinder
parent 391e5bd813
commit dfe896dd54
2 changed files with 4 additions and 1 deletions

View File

@@ -161,6 +161,9 @@ function optimiseIndexGetter(path, argsId, offset) {
if (t.isNumericLiteral(path.parent.property)) {
index = t.numericLiteral(path.parent.property.value + offset);
} else if (offset === 0) {
// Avoid unnecessary '+ 0'
index = path.parent.property;
} else {
index = t.binaryExpression("+", path.parent.property, t.numericLiteral(offset));
}

View File

@@ -2,5 +2,5 @@ function first() {
var _ref;
var index = 0;
return _ref = index++ + 0, arguments.length <= _ref ? undefined : arguments[_ref];
return _ref = index++, arguments.length <= _ref ? undefined : arguments[_ref];
}