Optimize out a lot of std::string construction and allocations (#415)

Update CommandLineParameters.hpp

Update CommandLineParametersTests.cpp

Update WebContext.hpp

xmake check-files -f

Fix MaterialPassRegistry
This commit is contained in:
Jérôme Leclercq
2023-12-30 14:50:57 +01:00
committed by GitHub
parent f7c9060364
commit 79ec135af7
57 changed files with 219 additions and 210 deletions

View File

@@ -262,7 +262,7 @@ namespace Nz
return true;
}
void MD5AnimParser::Error(const std::string& message)
void MD5AnimParser::Error(std::string_view message)
{
NazaraErrorFmt("{0} at line #{1}", message, m_lineCount);
}
@@ -504,14 +504,14 @@ namespace Nz
return true;
}
void MD5AnimParser::Warning(const std::string& message)
void MD5AnimParser::Warning(std::string_view message)
{
NazaraWarning(message + " at line #" + NumberToString(m_lineCount));
NazaraWarningFmt("{0} at line #{1}", message, m_lineCount);
}
void MD5AnimParser::UnrecognizedLine(bool error)
{
std::string message = "Unrecognized \"" + m_currentLine + '"';
std::string message = "unrecognized \"" + m_currentLine + '"';
if (error)
Error(message);

View File

@@ -209,7 +209,7 @@ namespace Nz
return true;
}
void MD5MeshParser::Error(const std::string& message)
void MD5MeshParser::Error(std::string_view message)
{
NazaraErrorFmt("{0} on line #{1}", message, m_lineCount);
}
@@ -444,14 +444,14 @@ namespace Nz
return true;
}
void MD5MeshParser::Warning(const std::string& message)
void MD5MeshParser::Warning(std::string_view message)
{
NazaraWarningFmt("{0} on line #{1}", message, m_lineCount);
}
void MD5MeshParser::UnrecognizedLine(bool error)
{
std::string message = "Unrecognized \"" + m_currentLine + '"';
std::string message = "unrecognized \"" + m_currentLine + '"';
if (error)
Error(message);

View File

@@ -14,7 +14,7 @@ namespace Nz
namespace
{
template<std::size_t N>
bool TestKeyword(const std::string& currentLine, const char(&keyword)[N], std::size_t& offset)
bool TestKeyword(std::string_view currentLine, const char(&keyword)[N], std::size_t& offset)
{
if (currentLine.size() > N && StartsWith(currentLine, keyword, CaseIndependent{}) && std::isspace(currentLine[N - 1]))
{

View File

@@ -57,7 +57,7 @@ namespace Nz
return (extension == ".obj");
}
bool SaveOBJToStream(const Mesh& mesh, const std::string& format, Stream& stream, const MeshParams& parameters)
bool SaveOBJToStream(const Mesh& mesh, std::string_view format, Stream& stream, const MeshParams& parameters)
{
NAZARA_USE_ANONYMOUS_NAMESPACE

View File

@@ -235,7 +235,7 @@ namespace Nz
return s_formatHandlers.find(extension) != s_formatHandlers.end();
}
bool SaveToStream(const Image& image, const std::string& format, Stream& stream, const ImageParams& parameters)
bool SaveToStream(const Image& image, std::string_view format, Stream& stream, const ImageParams& parameters)
{
NazaraUnused(parameters);
@@ -252,7 +252,7 @@ namespace Nz
return false;
}
auto it = s_formatHandlers.find(std::string_view(format));
auto it = s_formatHandlers.find(format);
NazaraAssert(it != s_formatHandlers.end(), "Invalid handler");
const FormatHandler& handler = it->second;