From 215dc3cc26bf0230fe671849f3448a0ed6123019 Mon Sep 17 00:00:00 2001 From: Dmytro Brahinets Date: Thu, 26 Jun 2025 19:50:26 +0300 Subject: [PATCH] Update 4-bad.js --- JavaScript/4-bad.js | 3 +++ 1 file changed, 3 insertions(+) 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); }