CResTypeFilter: Make use of ranged for where applicable
We can also collapse a loop down into a std::any_of.
This commit is contained in:
parent
5ce6b972a0
commit
b77f52bb0e
|
@ -5,6 +5,8 @@
|
||||||
#include "CResTypeInfo.h"
|
#include "CResTypeInfo.h"
|
||||||
#include "Core/GameProject/CResourceEntry.h"
|
#include "Core/GameProject/CResourceEntry.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
class CResTypeFilter
|
class CResTypeFilter
|
||||||
{
|
{
|
||||||
EGame mGame = EGame::Invalid;
|
EGame mGame = EGame::Invalid;
|
||||||
|
@ -19,9 +21,9 @@ public:
|
||||||
mAcceptedTypes.clear();
|
mAcceptedTypes.clear();
|
||||||
mGame = Game;
|
mGame = Game;
|
||||||
|
|
||||||
for (auto Iter = rkTypes.begin(); Iter != rkTypes.end(); Iter++)
|
for (const auto& str : rkTypes)
|
||||||
{
|
{
|
||||||
CResTypeInfo *pTypeInfo = CResTypeInfo::TypeForCookedExtension(mGame, CFourCC(*Iter));
|
CResTypeInfo* pTypeInfo = CResTypeInfo::TypeForCookedExtension(mGame, CFourCC(str));
|
||||||
|
|
||||||
if (pTypeInfo)
|
if (pTypeInfo)
|
||||||
mAcceptedTypes.insert(pTypeInfo->Type());
|
mAcceptedTypes.insert(pTypeInfo->Type());
|
||||||
|
@ -32,10 +34,12 @@ public:
|
||||||
{
|
{
|
||||||
TString Out;
|
TString Out;
|
||||||
|
|
||||||
for (auto Iter = mAcceptedTypes.begin(); Iter != mAcceptedTypes.end(); Iter++)
|
for (const auto type : mAcceptedTypes)
|
||||||
{
|
{
|
||||||
if (!Out.IsEmpty()) Out += ',';
|
if (!Out.IsEmpty())
|
||||||
CResTypeInfo *pTypeInfo = CResTypeInfo::FindTypeInfo(*Iter);
|
Out += ',';
|
||||||
|
|
||||||
|
CResTypeInfo *pTypeInfo = CResTypeInfo::FindTypeInfo(type);
|
||||||
Out += pTypeInfo->CookedExtension(mGame).ToString();
|
Out += pTypeInfo->CookedExtension(mGame).ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,15 +72,10 @@ public:
|
||||||
return pEntry && Accepts(pEntry->ResourceType());
|
return pEntry && Accepts(pEntry->ResourceType());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Accepts(const CResTypeFilter& rkFilter) const
|
bool Accepts(const CResTypeFilter& filter) const
|
||||||
{
|
{
|
||||||
for (auto Iter = mAcceptedTypes.begin(); Iter != mAcceptedTypes.end(); Iter++)
|
return std::any_of(mAcceptedTypes.cbegin(), mAcceptedTypes.cend(),
|
||||||
{
|
[&filter](const auto& entry) { return filter.Accepts(entry); });
|
||||||
if (rkFilter.Accepts(*Iter))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const CResTypeFilter& rkOther) const
|
bool operator==(const CResTypeFilter& rkOther) const
|
||||||
|
|
Loading…
Reference in New Issue