CCameraManager: Collapse loop into std::find_if in RemoveCameraShaker

We can collapse the loop into a find_if call here, since it only does a
look up and nothing more.
This commit is contained in:
Lioncash 2020-01-20 12:57:21 -05:00
parent b3fcbf9a89
commit b847930a85
1 changed files with 8 additions and 5 deletions

View File

@ -1,5 +1,7 @@
#include "Runtime/Camera/CCameraManager.hpp" #include "Runtime/Camera/CCameraManager.hpp"
#include <algorithm>
#include "Runtime/CStateManager.hpp" #include "Runtime/CStateManager.hpp"
#include "Runtime/GameGlobalObjects.hpp" #include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/Camera/CBallCamera.hpp" #include "Runtime/Camera/CBallCamera.hpp"
@ -38,11 +40,12 @@ zeus::CTransform CCameraManager::GetCurrentCameraTransform(const CStateManager&
} }
void CCameraManager::RemoveCameraShaker(u32 id) { void CCameraManager::RemoveCameraShaker(u32 id) {
for (auto it = x14_shakers.begin(); it != x14_shakers.end(); ++it) const auto iter = std::find_if(x14_shakers.cbegin(), x14_shakers.cend(),
if (it->xbc_shakerId == id) { [id](const auto& shaker) { return shaker.xbc_shakerId == id; });
x14_shakers.erase(it); if (iter == x14_shakers.cend()) {
break; return;
} }
x14_shakers.erase(iter);
} }
int CCameraManager::AddCameraShaker(const CCameraShakeData& data, bool sfx) { int CCameraManager::AddCameraShaker(const CCameraShakeData& data, bool sfx) {