CScriptTemplate: Collapse loop to find_if() in RemoveObject()
This commit is contained in:
parent
731e34b90b
commit
71fd2b8754
|
@ -5,6 +5,7 @@
|
|||
#include "Core/Resource/Animation/CAnimSet.h"
|
||||
#include <Common/Log.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
// Old constructor
|
||||
|
@ -286,16 +287,15 @@ void CScriptTemplate::AddObject(CScriptObject *pObject)
|
|||
mObjectList.push_back(pObject);
|
||||
}
|
||||
|
||||
void CScriptTemplate::RemoveObject(CScriptObject *pObject)
|
||||
void CScriptTemplate::RemoveObject(const CScriptObject *pObject)
|
||||
{
|
||||
for (auto it = mObjectList.begin(); it != mObjectList.end(); it++)
|
||||
{
|
||||
if (*it == pObject)
|
||||
{
|
||||
mObjectList.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
const auto iter = std::find_if(mObjectList.cbegin(), mObjectList.cend(),
|
||||
[pObject](const auto* ptr) { return ptr == pObject; });
|
||||
|
||||
if (iter == mObjectList.cend())
|
||||
return;
|
||||
|
||||
mObjectList.erase(iter);
|
||||
}
|
||||
|
||||
void CScriptTemplate::SortObjects()
|
||||
|
|
|
@ -172,7 +172,7 @@ public:
|
|||
uint32 NumObjects() const;
|
||||
const std::list<CScriptObject*>& ObjectList() const;
|
||||
void AddObject(CScriptObject *pObject);
|
||||
void RemoveObject(CScriptObject *pObject);
|
||||
void RemoveObject(const CScriptObject *pObject);
|
||||
void SortObjects();
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue