CMaterialSet: Collapse loop into find_if
Same behavior, explicit intent.
This commit is contained in:
parent
2d2210cd9e
commit
c8ebbc860b
|
@ -5,6 +5,7 @@
|
||||||
#include "CTexture.h"
|
#include "CTexture.h"
|
||||||
#include <Common/EGame.h>
|
#include <Common/EGame.h>
|
||||||
#include <Common/FileIO/IInputStream.h>
|
#include <Common/FileIO/IInputStream.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
class CMaterialSet
|
class CMaterialSet
|
||||||
{
|
{
|
||||||
|
@ -47,13 +48,13 @@ public:
|
||||||
|
|
||||||
CMaterial* MaterialByName(const TString& rkName)
|
CMaterial* MaterialByName(const TString& rkName)
|
||||||
{
|
{
|
||||||
for (auto it = mMaterials.begin(); it != mMaterials.end(); it++)
|
const auto iter = std::find_if(mMaterials.begin(), mMaterials.end(),
|
||||||
{
|
[&rkName](const auto& entry) { return entry->Name() == rkName; });
|
||||||
if ((*it)->Name() == rkName)
|
|
||||||
return it->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
if (iter == mMaterials.cend())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return iter->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 MaterialIndexByName(const TString& rkName)
|
uint32 MaterialIndexByName(const TString& rkName)
|
||||||
|
|
Loading…
Reference in New Issue