Skip to content

Commit

Permalink
Avoid unnecessary +0 in transform-es2015-parameters (babel#4738)
Browse files Browse the repository at this point in the history
  • Loading branch information
existentialism authored and chrisprice committed Oct 18, 2016
1 parent a1c00b5 commit 3142039
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/babel-plugin-transform-es2015-parameters/src/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

0 comments on commit 3142039

Please sign in to comment.