[*] Stupid optimization that doesn't make so much of a difference

This commit is contained in:
Reece Wilson 2022-03-31 14:12:06 +01:00
parent 76c4759f92
commit 2eb5c97800
2 changed files with 8 additions and 5 deletions

View File

@ -529,6 +529,7 @@ namespace Aurora::Loop
// Le great iterate
Iterator queueIterator(this);
AuSInt indexOffset {};
auto now = AuTime::CurrentInternalClockMS();
for (queueIterator.Start(); queueIterator.End() != queueIterator.itr; )
{
bool shouldRemove {true};
@ -576,7 +577,7 @@ namespace Aurora::Loop
}
if (!shouldRemove && source.ConsiderTimeout())
if (!shouldRemove && source.ConsiderTimeout(now))
{
shouldRemove = true;
}
@ -791,6 +792,7 @@ namespace Aurora::Loop
{
Iterator queueIterator(this);
AuSInt indexOffset {};
auto now = AuTime::CurrentInternalClockMS();
for (queueIterator.Start(); queueIterator.End() != queueIterator.itr; )
{
bool shouldRemove {false};
@ -879,7 +881,7 @@ namespace Aurora::Loop
}
else
{
if (source.ConsiderTimeout())
if (source.ConsiderTimeout(now))
{
shouldRemove = true;
}
@ -1009,11 +1011,12 @@ namespace Aurora::Loop
Iterator queueIterator(this);
bool bRebuildFromAnd {};
auto now = AuTime::CurrentInternalClockMS();
for (queueIterator.Start(); queueIterator.End() != queueIterator.itr; )
{
auto &source = *queueIterator.itr;
if (!source.ConsiderTimeout())
if (!source.ConsiderTimeout(now))
{
queueIterator.Next();
source.source->OnFinishSleep();

View File

@ -63,9 +63,9 @@ namespace Aurora::Loop
AuUInt32 timeoutAbs;
SourceCallbacks callbacks;
bool ConsiderTimeout() const
bool ConsiderTimeout(AuUInt64 time) const
{
if ((timeoutAbs) && (AuTime::CurrentInternalClockMS() >= timeoutAbs))
if ((timeoutAbs) && (time >= timeoutAbs))
{
for (const auto &handler : callbacks.extended)
{