CGameProject: Make use of std::string_view where applicable
Makes a few functions have non-allocating arguments
This commit is contained in:
parent
6d98e918ae
commit
bb9947fe0e
|
@ -39,7 +39,7 @@ void CAudioManager::LoadAssets()
|
|||
}
|
||||
|
||||
// Load audio lookup table + sfx name list
|
||||
const TString AudioLookupName = (mpProject->Game() < EGame::EchoesDemo ? "sound_lookup" : "sound_lookup_ATBL");
|
||||
const std::string_view AudioLookupName = mpProject->Game() < EGame::EchoesDemo ? "sound_lookup" : "sound_lookup_ATBL";
|
||||
const CAssetID AudioLookupID = mpProject->FindNamedResource(AudioLookupName);
|
||||
|
||||
if (AudioLookupID.IsValid())
|
||||
|
|
|
@ -148,7 +148,7 @@ void CGameProject::GetWorldList(std::list<CAssetID>& rOut) const
|
|||
}
|
||||
}
|
||||
|
||||
CAssetID CGameProject::FindNamedResource(const TString& rkName) const
|
||||
CAssetID CGameProject::FindNamedResource(std::string_view name) const
|
||||
{
|
||||
for (const auto& pkg : mPackages)
|
||||
{
|
||||
|
@ -156,7 +156,7 @@ CAssetID CGameProject::FindNamedResource(const TString& rkName) const
|
|||
{
|
||||
const SNamedResource& rkRes = pkg->NamedResourceByIndex(iRes);
|
||||
|
||||
if (rkRes.Name == rkName)
|
||||
if (rkRes.Name == name)
|
||||
return rkRes.ID;
|
||||
}
|
||||
}
|
||||
|
@ -164,17 +164,15 @@ CAssetID CGameProject::FindNamedResource(const TString& rkName) const
|
|||
return CAssetID::InvalidID(mGame);
|
||||
}
|
||||
|
||||
CPackage* CGameProject::FindPackage(const TString& rkName) const
|
||||
CPackage* CGameProject::FindPackage(std::string_view name) const
|
||||
{
|
||||
for (const auto& pPackage : mPackages)
|
||||
{
|
||||
if (pPackage->Name() == rkName)
|
||||
{
|
||||
return pPackage.get();
|
||||
}
|
||||
}
|
||||
const auto iter = std::find_if(mPackages.begin(), mPackages.end(),
|
||||
[name](const auto& package) { return package->Name() == name; });
|
||||
|
||||
return nullptr;
|
||||
if (iter == mPackages.cend())
|
||||
return nullptr;
|
||||
|
||||
return iter->get();
|
||||
}
|
||||
|
||||
std::unique_ptr<CGameProject> CGameProject::CreateProjectForExport(
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <Common/TString.h>
|
||||
#include <Common/FileIO/CFileLock.h>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
namespace nod { class DiscWii; }
|
||||
|
||||
|
@ -57,8 +58,8 @@ public:
|
|||
bool BuildISO(const TString& rkIsoPath, IProgressNotifier *pProgress);
|
||||
bool MergeISO(const TString& rkIsoPath, nod::DiscWii *pOriginalIso, IProgressNotifier *pProgress);
|
||||
void GetWorldList(std::list<CAssetID>& rOut) const;
|
||||
CAssetID FindNamedResource(const TString& rkName) const;
|
||||
CPackage* FindPackage(const TString& rkName) const;
|
||||
CAssetID FindNamedResource(std::string_view name) const;
|
||||
CPackage* FindPackage(std::string_view name) const;
|
||||
|
||||
// Static
|
||||
static std::unique_ptr<CGameProject> CreateProjectForExport(
|
||||
|
|
Loading…
Reference in New Issue