Optimize text formatting functions instantiation to favor manually called String::Format

This commit is contained in:
Wojtek Figat
2023-05-09 16:38:59 +02:00
parent a403c4d9ee
commit e03516e22e
8 changed files with 15 additions and 17 deletions

View File

@@ -409,17 +409,15 @@ public:
public:
void Error(const String& msg);
void Error(const StringView& msg);
void Error(const String& msg)
{
Error(StringView(msg));
}
void Error(const Char* msg)
{
Error(String(msg));
}
template<typename... Args>
void Error(const Char* format, const Args& ... args)
{
const String msg = String::Format(format, args...);
Error(msg);
Error(StringView(msg));
}
};

View File

@@ -343,7 +343,7 @@ void CookingData::AddRootEngineAsset(const String& internalPath)
}
}
void CookingData::Error(const String& msg)
void CookingData::Error(const StringView& msg)
{
LOG_STR(Error, msg);
}

View File

@@ -314,7 +314,7 @@ bool AndroidPlatformTools::OnPostProcess(CookingData& data)
const int32 result = Platform::CreateProcess(procSettings);
if (result != 0)
{
data.Error(TEXT("Failed to build Gradle project into package (result code: {0}). See log for more info."), result);
data.Error(String::Format(TEXT("Failed to build Gradle project into package (result code: {0}). See log for more info."), result));
return true;
}

View File

@@ -52,7 +52,7 @@ bool GDKPlatformTools::OnDeployBinaries(CookingData& data)
files.Add(binPath / executableFilename);
if (!FileSystem::FileExists(files[0]))
{
data.Error(TEXT("Missing executable file ({0})."), files[0]);
data.Error(String::Format(TEXT("Missing executable file ({0})."), files[0]));
return true;
}
FileSystem::DirectoryGetFiles(files, binPath, TEXT("*.dll"), DirectorySearchOption::TopDirectoryOnly);
@@ -60,7 +60,7 @@ bool GDKPlatformTools::OnDeployBinaries(CookingData& data)
{
if (FileSystem::CopyFile(data.NativeCodeOutputPath / StringUtils::GetFileName(files[i]), files[i]))
{
data.Error(TEXT("Failed to setup output directory (file {0})."), files[i]);
data.Error(String::Format(TEXT("Failed to setup output directory (file {0})."), files[i]));
return true;
}
}

View File

@@ -65,7 +65,7 @@ bool UWPPlatformTools::OnDeployBinaries(CookingData& data)
{
if (!FileSystem::FileExists(files[i]))
{
data.Error(TEXT("Missing source file {0}."), files[i]);
data.Error(String::Format(TEXT("Missing source file {0}."), files[i]));
return true;
}

View File

@@ -129,7 +129,7 @@ bool CompileScriptsStep::DeployBinaries(CookingData& data, const String& path, c
continue;
if (FileSystem::CopyFile(dst, file))
{
data.Error(TEXT("Failed to copy file from {0} to {1}."), file, dst);
data.Error(String::Format(TEXT("Failed to copy file from {0} to {1}."), file, dst));
return true;
}

View File

@@ -410,7 +410,7 @@ bool ProcessShaderBase(CookAssetsStep::AssetCookData& data, ShaderAssetBase* ass
assetBase->InitCompilationOptions(options); \
if (ShadersCompilation::Compile(options)) \
{ \
data.Data.Error(TEXT("Failed to compile shader '{0}' (profile: {1})."), asset->ToString(), ::ToString(options.Profile)); \
data.Data.Error(String::Format(TEXT("Failed to compile shader '{0}' (profile: {1})."), asset->ToString(), ::ToString(options.Profile))); \
return true; \
} \
includes.Clear(); \

View File

@@ -13,7 +13,7 @@
/// <summary>
/// Sends a formatted message to the log file (message type - describes level of the log (see LogType enum))
/// </summary>
#define LOG(messageType, format, ...) Log::Logger::Write(LogType::messageType, TEXT(format), ##__VA_ARGS__)
#define LOG(messageType, format, ...) Log::Logger::Write(LogType::messageType, ::String::Format(TEXT(format), ##__VA_ARGS__))
/// <summary>
/// Sends a string message to the log file (message type - describes level of the log (see LogType enum))