⚡️ Performance: Investigate using a Set to store actors, not an array #135
Labels
status: needs investigation
Further research required...? 🔎
type: feature
New enhancement or request 🚀
Bug Report Checklist
main
branch of the repository.Overview
Right now,
emojisplosion
internally uses an theAnimator
class to run the regular gameplay loop of tellingEmojiActor
s ("actors") to animate. It stores actors in an array internally:https://github.com/JoshuaKGoldberg/emojisplosion/blob/fe1ef216a89d6dd32bc5e752e203ceb66206c6d7/src/animator.ts#L11-L14
Whenever an actor "dies" (leaves the screen area), it's removed from that array with a
.splice
:https://github.com/JoshuaKGoldberg/emojisplosion/blob/fe1ef216a89d6dd32bc5e752e203ceb66206c6d7/src/animator.ts#L52-L57
I wonder if that's actually inefficient? Now that all browsers have
Set
s, should we look into going with aSet
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.
The text was updated successfully, but these errors were encountered: