Skip to content

Optimize even more #2

@Andarist

Description

@Andarist

You'd probably get even better results if you remove the function calls within loop. You have to be careful about inserted identifiers and such, but it should be fairly easy to generate this:

// Compiled with faster.js
const arr = [1, 2, 3];
const results = [];
for (let _i = 0; _i < arr.length; _i++) {
  results.push(2 * arr[_i]);
}

Maybe you could even preallocate results in case of .map based on arr.length, but aint sure what's better in majority of use cases. Maybe you could decide about this based on this comment from v8 team.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions