Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions JavaScript/4-bad.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down