Skip to content

Commit

Permalink
Simplify timer logic.
Browse files Browse the repository at this point in the history
We aren't using `i`, so we can iterate over the array normally. And there are no longer null entries, so we don't have to check for those.
  • Loading branch information
player-03 authored Sep 6, 2024
1 parent 7cad516 commit 3554bfe
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/lime/_internal/backend/native/NativeApplication.hx
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@ class NativeApplication
if (pauseTimer > -1)
{
var offset = System.getTimer() - pauseTimer;
for (i in 0...Timer.sRunningTimers.length)
for (timer in Timer.sRunningTimers)
{
var timer = Timer.sRunningTimers[i];
if (timer != null && timer.mRunning) timer.mFireAt += offset;
if (timer.mRunning) timer.mFireAt += offset;
}
pauseTimer = -1;
}
Expand Down Expand Up @@ -579,14 +578,11 @@ class NativeApplication
if (Timer.sRunningTimers.length > 0)
{
var currentTime = System.getTimer();
var foundNull = false;
var timer;
var foundStopped = false;

for (i in 0...Timer.sRunningTimers.length)
for (timer in Timer.sRunningTimers)
{
timer = Timer.sRunningTimers[i];

if (timer != null && timer.mRunning)
if (timer.mRunning)
{
if (currentTime >= timer.mFireAt)
{
Expand All @@ -596,15 +592,15 @@ class NativeApplication
}
else
{
foundNull = true;
foundStopped = true;
}
}

if (foundNull)
if (foundStopped)
{
Timer.sRunningTimers = Timer.sRunningTimers.filter(function(val)
{
return val != null && val.mRunning;
return val.mRunning;
});
}
}
Expand Down

0 comments on commit 3554bfe

Please sign in to comment.