Speed up timer update by using Map.forEach
According to JIT profiling on SM 115, using ForEach is faster than iterating. This is a micro optimisation, maybe 2% faster for OnUpdate, which means we might see an overall improvement < 0.4%. The reason this is faster here is that Iterating needs to construct an array to store the result, whereas ForEach just uses the values directly. This means this probably doesn't apply to iterating if we don't need both the key/value pair. Differential Revision: https://code.wildfiregames.com/D5010 This was SVN commit r27674.
This commit is contained in:
parent
7350b9042e
commit
3991c5c857
@ -114,9 +114,10 @@ Timer.prototype.OnUpdate = function(msg)
|
||||
// (We do this in two stages to avoid deleting from the timer list while
|
||||
// we're in the middle of iterating through it)
|
||||
let run = [];
|
||||
for (let [id, timer] of this.timers)
|
||||
this.timers.forEach((timer, id) => {
|
||||
if (timer.time <= this.time)
|
||||
run.push(id);
|
||||
});
|
||||
|
||||
for (let id of run)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user