summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2022-03-05 19:09:32 +0100
committerLéo Lam <leo@leolam.fr>2022-03-05 19:13:06 +0100
commit88a0a9eb691a3c1925e9b5d185fb12550618e5f8 (patch)
treeec055bc9747a1c01d45231eadc204858af39422f /src
parentd839816081398859f95668e2c5aad872d24919f0 (diff)
Use sead::OffsetList::robustRange() when possible to simplify iteration
Diffstat (limited to 'src')
-rw-r--r--src/KingSystem/ActorSystem/actBaseProcMgr.cpp9
-rw-r--r--src/KingSystem/Resource/resResourceMgrTask.cpp6
-rw-r--r--src/KingSystem/System/OverlayArena.cpp4
-rw-r--r--src/KingSystem/Utils/Thread/TaskQueueBase.cpp6
4 files changed, 12 insertions, 13 deletions
diff --git a/src/KingSystem/ActorSystem/actBaseProcMgr.cpp b/src/KingSystem/ActorSystem/actBaseProcMgr.cpp
index ecf03b66..9c8c59be 100644
--- a/src/KingSystem/ActorSystem/actBaseProcMgr.cpp
+++ b/src/KingSystem/ActorSystem/actBaseProcMgr.cpp
@@ -310,11 +310,10 @@ void BaseProcMgr::calc() {
for (auto& proc : mProcUpdateStateList)
proc.processStateUpdate(mCounter);
- for (auto it = mProcUpdateStateList.robustBegin(), end = mProcUpdateStateList.robustEnd();
- it != end; ++it) {
- it->afterUpdateState_();
- if (it->mStateFlags.isZero()) {
- mProcUpdateStateList.erase(std::addressof(*it));
+ for (auto& proc : mProcUpdateStateList.robustRange()) {
+ proc.afterUpdateState_();
+ if (proc.mStateFlags.isZero()) {
+ mProcUpdateStateList.erase(&proc);
}
}
diff --git a/src/KingSystem/Resource/resResourceMgrTask.cpp b/src/KingSystem/Resource/resResourceMgrTask.cpp
index bda7572e..dc66c94c 100644
--- a/src/KingSystem/Resource/resResourceMgrTask.cpp
+++ b/src/KingSystem/Resource/resResourceMgrTask.cpp
@@ -644,9 +644,9 @@ void ResourceMgrTask::clearUnits_() {
if (num_units != 0 && returnFalse())
stubbedLogFunction();
- for (auto it = mUnits.robustBegin(), end = mUnits.robustEnd(); it != end; ++it) {
- ResourceUnit* unit = &*it;
- if (it->mTask3.canSubmitRequest()) {
+ for (auto& unit_ref : mUnits.robustRange()) {
+ ResourceUnit* unit = &unit_ref;
+ if (unit->mTask3.canSubmitRequest()) {
mUnits.erase(unit);
requestClearCache(&unit);
}
diff --git a/src/KingSystem/System/OverlayArena.cpp b/src/KingSystem/System/OverlayArena.cpp
index 62ae8a8c..271c922d 100644
--- a/src/KingSystem/System/OverlayArena.cpp
+++ b/src/KingSystem/System/OverlayArena.cpp
@@ -73,8 +73,8 @@ void OverlayArena::clearUnits() {
res::stubbedLogFunction();
auto lock = sead::makeScopedLock(mCS);
- for (auto it = mUnits.robustBegin(), end = mUnits.robustEnd(); it != end; ++it) {
- res::ResourceUnit* unit = std::addressof(*it);
+ for (auto& unit_ref : mUnits.robustRange()) {
+ res::ResourceUnit* unit = &unit_ref;
res::stubbedLogFunction();
res::ResourceMgrTask::instance()->deregisterUnit(unit);
res::ResourceMgrTask::instance()->requestClearCacheForSync(&unit, true, false);
diff --git a/src/KingSystem/Utils/Thread/TaskQueueBase.cpp b/src/KingSystem/Utils/Thread/TaskQueueBase.cpp
index 0e8853c8..5310726c 100644
--- a/src/KingSystem/Utils/Thread/TaskQueueBase.cpp
+++ b/src/KingSystem/Utils/Thread/TaskQueueBase.cpp
@@ -31,9 +31,9 @@ void TaskQueueBase::clear() {
lock();
// Clear all tasks.
- for (auto it = mActiveTasks.robustBegin(), end = mActiveTasks.robustEnd(); it != end; ++it) {
- mActiveTasks.erase(std::addressof(*it));
- it->onRemove();
+ for (auto& task : mActiveTasks.robustRange()) {
+ mActiveTasks.erase(&task);
+ task.onRemove();
}
mActiveTasks.clear();