diff --git a/JavaScript/4-improved.js b/JavaScript/4-improved.js index 20a016e..aa45b0f 100644 --- a/JavaScript/4-improved.js +++ b/JavaScript/4-improved.js @@ -1,7 +1,13 @@ 'use strict'; const poolify = (factory, { size, max }) => { - const instances = new Array(size).fill(null).map(factory); + // It seems that preallocated array with defined size + // and using c-like for-loop will be more efficient in terms of V8 optimisation than + // const instances = new Array(size).fill(null).map(factory); + const instances = new Array(size); + for(let i = 0; i < size; i++){ + instances[i] = factory(); + } const acquire = () => instances.pop() || factory(); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy