From c980df518884347911014e5315dd37436690b6cf Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 16 Jun 2020 14:17:26 -0400 Subject: [PATCH] CSourceAnimData: Make use of ranged for where applicable --- src/Core/Resource/Animation/CSourceAnimData.h | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/Core/Resource/Animation/CSourceAnimData.h b/src/Core/Resource/Animation/CSourceAnimData.h index d1a2b4af..dd068a9f 100644 --- a/src/Core/Resource/Animation/CSourceAnimData.h +++ b/src/Core/Resource/Animation/CSourceAnimData.h @@ -46,11 +46,11 @@ public: void GetUniquePrimitives(std::set& rPrimSet) const { - for (uint32 TransIdx = 0; TransIdx < mTransitions.size(); TransIdx++) - mTransitions[TransIdx].pTransition->GetUniquePrimitives(rPrimSet); + for (const auto& transition : mTransitions) + transition.pTransition->GetUniquePrimitives(rPrimSet); - for (uint32 HalfIdx = 0; HalfIdx < mHalfTransitions.size(); HalfIdx++) - mHalfTransitions[HalfIdx].pTransition->GetUniquePrimitives(rPrimSet); + for (const auto& halfTrans : mHalfTransitions) + halfTrans.pTransition->GetUniquePrimitives(rPrimSet); if (mpDefaultTransition) mpDefaultTransition->GetUniquePrimitives(rPrimSet); @@ -66,33 +66,31 @@ public: // Find all relevant primitives std::set PrimSet; - if (UsedTransitions.find(mpDefaultTransition.get()) == UsedTransitions.end()) + if (UsedTransitions.find(mpDefaultTransition.get()) == UsedTransitions.cend()) { mpDefaultTransition->GetUniquePrimitives(PrimSet); UsedTransitions.insert(mpDefaultTransition.get()); } - for (uint32 TransitionIdx = 0; TransitionIdx < mTransitions.size(); TransitionIdx++) + for (const STransition& transition : mTransitions) { - const STransition& rkTransition = mTransitions[TransitionIdx]; - IMetaTransition *pTransition = rkTransition.pTransition.get(); + IMetaTransition *pTransition = transition.pTransition.get(); - if ( pTree->HasDependency(rkTransition.AnimA) && - pTree->HasDependency(rkTransition.AnimB) && - UsedTransitions.find(pTransition) == UsedTransitions.end() ) + if (pTree->HasDependency(transition.AnimA) && + pTree->HasDependency(transition.AnimB) && + UsedTransitions.find(pTransition) == UsedTransitions.cend()) { pTransition->GetUniquePrimitives(PrimSet); UsedTransitions.insert(pTransition); } } - for (uint32 HalfIdx = 0; HalfIdx < mHalfTransitions.size(); HalfIdx++) + for (const SHalfTransition& halfTrans : mHalfTransitions) { - const SHalfTransition& rkHalfTrans = mHalfTransitions[HalfIdx]; - IMetaTransition *pTransition = rkHalfTrans.pTransition.get(); + IMetaTransition *pTransition = halfTrans.pTransition.get(); - if ( pTree->HasDependency(rkHalfTrans.Anim) && - UsedTransitions.find(pTransition) == UsedTransitions.end() ) + if (pTree->HasDependency(halfTrans.Anim) && + UsedTransitions.find(pTransition) == UsedTransitions.cend()) { pTransition->GetUniquePrimitives(PrimSet); UsedTransitions.insert(pTransition); @@ -104,8 +102,8 @@ public: break; // Add all transition primitives to the tree - for (auto Iter = PrimSet.begin(); Iter != PrimSet.end(); Iter++) - pTree->AddDependency(Iter->Animation()); + for (auto& primitive : PrimSet) + pTree->AddDependency(primitive.Animation()); } } };