I need to populate an array with a large number of objects. Currently, my approach looks like this:
let useVertices = [];
const len = this.indices.length;
for(let i = 0; i < len; i++){
let index = this.indices[i]*3;
useVertices.push(new THREE.Vector3(
this.vertices[index],
this.vertices[index+1],
this.vertices[index+2])
);
}
this.indices
is an Int32Array that contains nearly 4 million elements.
this.vertices
is a Float32Array with around 650,000 elements.
The current implementation usually takes between 500 and 800 ms to complete.
I am using CefSharp as the browser since the website is running within a C# application.
Are there any ways to optimize this code for faster performance?