diff --git a/JavaScript/4-bad.js b/JavaScript/4-bad.js index a706074..a51dcb1 100644 --- a/JavaScript/4-bad.js +++ b/JavaScript/4-bad.js @@ -6,6 +6,9 @@ const poolify = (factory, options, size, max) => { const instances = []; // Preallocate array for (let i = 0; i < size; i++) { // Use Array methods instead of loop + // In this case destructuring will be optimized by V8 + // https://github.com/v8/v8/blob/074bb97050edcb45ca33b250ebcb865279e61dd4/src/compiler/js-call-reducer.cc#L4542 + // It will change function to direct ::Call() that is C++ function instead of creation of iterator const instance = factory(...options); // Avoid array destructuring instances.push(instance); }