Although the difference is too small to be caught by our current automated benchmark tests.
When JIT is available, using an Array would be more performant, but given we are targeting game consoles as our main platform and they don't have JIT available, a Set with a forEach is the better option.
To test without JIT, I have used Chrome with the flag --js-flags="--jitless".
Using the https://esbench.com/bench/6317fc2a6c89f600a5701bc9 in a JIT less environment, we confirmed this method to be the fastest to loop the listeners:
Although the difference is too small to be caught by our current automated benchmark tests.
When JIT is available, using an
Array
would be more performant, but given we are targeting game consoles as our main platform and they don't have JIT available, aSet
with aforEach
is the better option.To test without JIT, I have used Chrome with the flag
--js-flags="--jitless"
.