Avoid unnecessary +0 in transform-es2015-parameters (#4738)
This commit is contained in:
committed by
Daniel Tschinder
parent
391e5bd813
commit
dfe896dd54
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user