[Config] Use std::less<> for std::map<...>

Reduces amount of string copies
[Utilities] fmt::replace_all: avoid creation of temporary strings
This commit is contained in:
DH 2021-11-28 09:30:41 +02:00 committed by Nekotekina
parent 2981867375
commit cccfb89aa0
14 changed files with 80 additions and 62 deletions

View file

@ -135,7 +135,7 @@ namespace gl
" %vars"
"\n";
const std::pair<std::string, std::string> syntax_replace[] =
const std::pair<std::string_view, std::string> syntax_replace[] =
{
{ "%loc", std::to_string(GL_COMPUTE_BUFFER_SLOT(0)) },
{ "%ws", std::to_string(optimal_group_size) },

View file

@ -139,7 +139,7 @@ std::string CgBinaryDisasm::GetCondDisAsm() const
std::string CgBinaryDisasm::FormatDisAsm(const std::string& code)
{
const std::pair<std::string, std::function<std::string()>> repl_list[] =
const std::pair<std::string_view, std::function<std::string()>> repl_list[] =
{
{ "$$", []() -> std::string { return "$"; } },
{ "$0", [this]{ return GetSrcDisAsm<SRC0>(src0); } },

View file

@ -180,7 +180,7 @@ std::string CgBinaryDisasm::GetTexDisasm()
std::string CgBinaryDisasm::FormatDisasm(const std::string& code)
{
const std::pair<std::string, std::function<std::string()>> repl_list[] =
const std::pair<std::string_view, std::function<std::string()>> repl_list[] =
{
{ "$$", []() -> std::string { return "$"; } },
{ "$0", [this]{ return GetSRCDisasm(0); } },

View file

@ -330,7 +330,7 @@ bool FragmentProgramDecompiler::DstExpectsSca() const
std::string FragmentProgramDecompiler::Format(const std::string& code, bool ignore_redirects)
{
const std::pair<std::string, std::function<std::string()>> repl_list[] =
const std::pair<std::string_view, std::function<std::string()>> repl_list[] =
{
{ "$$", []() -> std::string { return "$"; } },
{ "$0", [this]() -> std::string {return GetSRC<SRC0>(src0);} },
@ -369,7 +369,7 @@ std::string FragmentProgramDecompiler::Format(const std::string& code, bool igno
{
//Redirect parameter 0 to the x2d temp register for TEXBEM
//TODO: Organize this a little better
std::pair<std::string, std::string> repl[] = { { "$0", "x2d" } };
std::pair<std::string_view, std::string> repl[] = { { "$0", "x2d" } };
std::string result = fmt::replace_all(code, repl);
return fmt::replace_all(result, repl_list);

View file

@ -122,7 +122,7 @@ namespace program_common
" return result;\n"
"}\n\n";
std::pair<std::string, std::string> replacements[] =
std::pair<std::string_view, std::string> replacements[] =
{std::make_pair("$T", wide_vector_type),
std::make_pair("$I", input_coord)};

View file

@ -222,7 +222,7 @@ std::string VertexProgramDecompiler::GetTex()
std::string VertexProgramDecompiler::Format(const std::string& code)
{
const std::pair<std::string, std::function<std::string()>> repl_list[] =
const std::pair<std::string_view, std::function<std::string()>> repl_list[] =
{
{ "$$", []() -> std::string { return "$"; } },
{ "$0", std::bind(std::mem_fn(&VertexProgramDecompiler::GetSRC), this, 0) },

View file

@ -251,7 +251,7 @@ namespace vk
"\n";
const auto parameters_size = utils::align(push_constants_size, 16) / 16;
const std::pair<std::string, std::string> syntax_replace[] =
const std::pair<std::string_view, std::string> syntax_replace[] =
{
{ "%ws", std::to_string(optimal_group_size) },
{ "%ks", std::to_string(kernel_size) },
@ -396,7 +396,7 @@ namespace vk
" }\n"
"}\n";
const std::pair<std::string, std::string> syntax_replace[] =
const std::pair<std::string_view, std::string> syntax_replace[] =
{
{ "%ws", std::to_string(optimal_group_size) },
};

View file

@ -565,7 +565,7 @@ namespace vk
}
}
const std::pair<std::string, std::string> syntax_replace[] =
const std::pair<std::string_view, std::string> syntax_replace[] =
{
{ "%ws", std::to_string(optimal_group_size) },
{ "%_wordcount", std::to_string(sizeof(_BlockType) / 4) },

View file

@ -21,6 +21,7 @@ namespace vk
virtual ~cs_resolve_base()
{}
// FIXME: move body to cpp
void build(const std::string& kernel, const std::string& format_prefix, int direction)
{
create();
@ -39,7 +40,7 @@ namespace vk
break;
}
const std::pair<std::string, std::string> syntax_replace[] =
const std::pair<std::string_view, std::string> syntax_replace[] =
{
{ "%wx", std::to_string(cs_wave_x) },
{ "%wy", std::to_string(cs_wave_y) },

View file

@ -227,7 +227,7 @@ namespace logs
}
}
void set_channel_levels(const std::map<std::string, logs::level>& map)
void set_channel_levels(const std::map<std::string, logs::level, std::less<>>& map)
{
for (auto&& pair : map)
{

View file

@ -164,7 +164,7 @@ namespace logs
level get_level(const std::string&);
// Log level control: set specific channels to level::fatal
void set_channel_levels(const std::map<std::string, logs::level>& map);
void set_channel_levels(const std::map<std::string, logs::level, std::less<>>& map);
// Get all registered log channels
std::vector<std::string> get_channels();