From 7ce0e14e2931725db918e1aeefa79921bb934d85 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 11 Jun 2020 13:21:33 -0400 Subject: [PATCH] CAssetNameMap: Eliminate file-scope string allocations --- src/Core/GameProject/CAssetNameMap.cpp | 12 ++++++++++-- src/Core/GameProject/CAssetNameMap.h | 7 ++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Core/GameProject/CAssetNameMap.cpp b/src/Core/GameProject/CAssetNameMap.cpp index e4d7c1a3..518f85ef 100644 --- a/src/Core/GameProject/CAssetNameMap.cpp +++ b/src/Core/GameProject/CAssetNameMap.cpp @@ -1,5 +1,8 @@ #include "CAssetNameMap.h" +constexpr char gkAssetMapPath[] = "resources/gameinfo/AssetNameMap"; +constexpr char gkAssetMapExt[] = "xml"; + bool CAssetNameMap::LoadAssetNames(TString Path /*= ""*/) { if (Path.IsEmpty()) @@ -194,11 +197,16 @@ void CAssetNameMap::PostLoadValidate() TString CAssetNameMap::DefaultNameMapPath(EIDLength IDLength) { ASSERT(IDLength != kInvalidIDLength); - TString Suffix = (IDLength == EIDLength::k32Bit ? "32" : "64"); - return gDataDir + gkAssetMapPath + Suffix + "." + gkAssetMapExt; + const char* const Suffix = (IDLength == EIDLength::k32Bit ? "32" : "64"); + return gDataDir + gkAssetMapPath + Suffix + '.' + gkAssetMapExt; } TString CAssetNameMap::DefaultNameMapPath(EGame Game) { return DefaultNameMapPath( CAssetID::GameIDLength(Game) ); } + +TString CAssetNameMap::GetExtension() +{ + return gkAssetMapExt; +} diff --git a/src/Core/GameProject/CAssetNameMap.h b/src/Core/GameProject/CAssetNameMap.h index 6fc78423..2f068eda 100644 --- a/src/Core/GameProject/CAssetNameMap.h +++ b/src/Core/GameProject/CAssetNameMap.h @@ -8,9 +8,6 @@ #include #include -const TString gkAssetMapPath = "resources/gameinfo/AssetNameMap"; -const TString gkAssetMapExt = "xml"; - class CAssetNameMap { struct SAssetNameInfo @@ -66,8 +63,8 @@ public: static TString DefaultNameMapPath(EIDLength IDLength); static TString DefaultNameMapPath(EGame Game); - inline bool IsValid() const { return mIsValid; } - inline static TString GetExtension() { return gkAssetMapExt; } + bool IsValid() const { return mIsValid; } + static TString GetExtension(); }; #endif // CASSETNAMEMAP