Comment by oxidant
3 days ago
Spreading arrays and objects is such a common performance hit. It works fine for small instances but falls over in large instances.
Here's the JS CRM engine https://github.com/nuejs/nue/blob/master/packages/examples/s...
I see a number of issues, but don't have time to look into them.
1. Spreading when you probably don't need a copy: sortEntries. Sorting is probably where the overflow happens. Just sort in place or use Array.from or slice.
2. Excessive use of array functions. In my experience, a C style for loop performs better when you need performance. Create an empty array before, perform your business logic inside the block, and push to the array.
3. I don't know how filter is called, but it potentially loops through all of the events three times in the worst case.
4. paginate manually creates a JSON string from the returned entries. I don't know why, it seems inefficient.
No comments yet
Contribute on Hacker News ↗