This commit is contained in:
parent
7a7704fea0
commit
0366d1ad19
@ -17,6 +17,10 @@ let restIndex = template(`
|
|||||||
ARGUMENTS.length <= INDEX ? undefined : ARGUMENTS[INDEX]
|
ARGUMENTS.length <= INDEX ? undefined : ARGUMENTS[INDEX]
|
||||||
`);
|
`);
|
||||||
|
|
||||||
|
let restIndexImpure = template(`
|
||||||
|
REF = INDEX, ARGUMENTS.length <= REF ? undefined : ARGUMENTS[REF]
|
||||||
|
`);
|
||||||
|
|
||||||
let restLength = template(`
|
let restLength = template(`
|
||||||
ARGUMENTS.length <= OFFSET ? 0 : ARGUMENTS.length - OFFSET
|
ARGUMENTS.length <= OFFSET ? 0 : ARGUMENTS.length - OFFSET
|
||||||
`);
|
`);
|
||||||
@ -161,11 +165,22 @@ function optimiseIndexGetter(path, argsId, offset) {
|
|||||||
index = t.binaryExpression("+", path.parent.property, t.numericLiteral(offset));
|
index = t.binaryExpression("+", path.parent.property, t.numericLiteral(offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { scope } = path;
|
||||||
|
if (!scope.isPure(index)) {
|
||||||
|
let temp = scope.generateUidIdentifierBasedOnNode(index);
|
||||||
|
scope.push({id: temp, kind: "var"});
|
||||||
|
path.parentPath.replaceWith(restIndexImpure({
|
||||||
|
ARGUMENTS: argsId,
|
||||||
|
INDEX: index,
|
||||||
|
REF: temp
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
path.parentPath.replaceWith(restIndex({
|
path.parentPath.replaceWith(restIndex({
|
||||||
ARGUMENTS: argsId,
|
ARGUMENTS: argsId,
|
||||||
INDEX: index,
|
INDEX: index,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function optimiseLengthGetter(path, argsId, offset) {
|
function optimiseLengthGetter(path, argsId, offset) {
|
||||||
if (offset) {
|
if (offset) {
|
||||||
|
|||||||
@ -0,0 +1,4 @@
|
|||||||
|
function first(...values) {
|
||||||
|
var index = 0;
|
||||||
|
return values[index++];
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
function first() {
|
||||||
|
var _ref;
|
||||||
|
|
||||||
|
var index = 0;
|
||||||
|
return _ref = index++ + 0, arguments.length <= _ref ? undefined : arguments[_ref];
|
||||||
|
}
|
||||||
@ -1,6 +1,8 @@
|
|||||||
var t = function (f) {
|
var t = function (f) {
|
||||||
|
var _ref;
|
||||||
|
|
||||||
arguments.length <= 1 ? undefined : arguments[1];
|
arguments.length <= 1 ? undefined : arguments[1];
|
||||||
arguments.length <= (arguments.length <= 1 ? 0 : arguments.length - 1) - 1 + 1 ? undefined : arguments[(arguments.length <= 1 ? 0 : arguments.length - 1) - 1 + 1];
|
_ref = (arguments.length <= 1 ? 0 : arguments.length - 1) - 1 + 1, arguments.length <= _ref ? undefined : arguments[_ref];
|
||||||
};
|
};
|
||||||
|
|
||||||
function t(f) {
|
function t(f) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user