Apply review suggestions, remove redundant comment

This commit is contained in:
ζeh Matt 2024-01-11 17:34:32 +02:00
parent c7a716e050
commit 88a0e4b8d4
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
1 changed files with 6 additions and 12 deletions

View File

@ -1597,16 +1597,10 @@ void ScriptEngine::SetParkStorageFromJSON(std::string_view value)
IntervalHandle ScriptEngine::AllocateHandle()
{
auto res = _nextIntervalHandle;
_nextIntervalHandle++;
// In case of overflow start from 1 again
if (_nextIntervalHandle == 0)
{
_nextIntervalHandle = 1;
}
_nextIntervalHandle = std::max(_nextIntervalHandle++, 1U);
return res;
return _nextIntervalHandle;
}
IntervalHandle ScriptEngine::AddInterval(const std::shared_ptr<Plugin>& plugin, int32_t delay, bool repeat, DukValue&& callback)
@ -1657,7 +1651,6 @@ void ScriptEngine::UpdateIntervals()
}
_lastIntervalTimestamp = timestamp;
// This loop needs to account for removal and insertions during iteration.
for (auto it = _intervals.begin(), itNext = it; it != _intervals.end(); it = itNext)
{
itNext++;
@ -1686,10 +1679,11 @@ void ScriptEngine::RemoveIntervals(const std::shared_ptr<Plugin>& plugin)
if (interval.Owner == plugin)
{
it = _intervals.erase(it);
continue;
}
it++;
else
{
it++;
}
}
}