Move slice iterator helper out of primary call
Avoids overhead of instantiating the helper on each call to the slice to array helper.
This commit is contained in:
parent
1b0e5b3ed1
commit
5353ccd773
@ -1,7 +1,7 @@
|
||||
(function (arr, i) {
|
||||
(function () {
|
||||
// Broken out into a separate function to avoid deoptimizations due to the try/catch for the
|
||||
// array iterator case.
|
||||
function sliceIterator() {
|
||||
function sliceIterator(arr, i) {
|
||||
// this is an expanded form of `for...of` that properly supports abrupt completions of
|
||||
// iterators etc. variable names have been minimised to reduce the size of this massive
|
||||
// helper. sometimes spec compliancy is annoying :(
|
||||
@ -34,11 +34,13 @@
|
||||
return _arr;
|
||||
}
|
||||
|
||||
if (Array.isArray(arr)) {
|
||||
return arr;
|
||||
} else if (Symbol.iterator in Object(arr)) {
|
||||
return sliceIterator();
|
||||
} else {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
||||
}
|
||||
});
|
||||
return function (arr, i) {
|
||||
if (Array.isArray(arr)) {
|
||||
return arr;
|
||||
} else if (Symbol.iterator in Object(arr)) {
|
||||
return sliceIterator(arr, i);
|
||||
} else {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user