Avoid trailing slice unless needed.

This commit is contained in:
John-David Dalton
2016-11-06 00:13:16 -07:00
parent e0a65ac34a
commit 6ef973ae33

View File

@@ -10819,12 +10819,15 @@
start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
return baseRest(function(args) {
var array = args[start],
lastIndex = args.length - 1,
otherArgs = castSlice(args, 0, start);
if (array) {
arrayPush(otherArgs, array);
}
arrayPush(otherArgs, castSlice(args, start + 1));
if (start != lastIndex) {
arrayPush(otherArgs, castSlice(args, start + 1));
}
return apply(func, this, otherArgs);
});
}