-
Notifications
You must be signed in to change notification settings - Fork 26
⚡️ Performance: Investigate using a Set to store actors, not an array #135
Description
Bug Report Checklist
- I have tried restarting my IDE and the issue persists.
- I have pulled the latest
mainbranch of the repository. - I have searched for related issues and found none that matched my issue.
Overview
Right now, emojisplosion internally uses an the Animator class to run the regular gameplay loop of telling EmojiActors ("actors") to animate. It stores actors in an array internally:
Whenever an actor "dies" (leaves the screen area), it's removed from that array with a .splice:
I wonder if that's actually inefficient? Now that all browsers have Sets, should we look into going with a Set for storage, so that it has O(1) removals?
Additional Info
...alternately, should we loop from the end of the actors array to the beginning (let i = actors.length - 1; i >= 0; i -= 1)?
Investigation needed!
Since this is a performance investigation, we'd need real data in multiple popular browsers (Chrome, Firefox, Safari) to indicate whether any approach is noticeably better or worse than others.