GraphicsMod: Simplify `std::sort` using ranges and projections

This commit is contained in:
mitaclaw 2024-10-05 16:08:01 -07:00
parent 2edf6c6419
commit 8b1975ab18
3 changed files with 1 additions and 8 deletions

View File

@ -330,8 +330,3 @@ void GraphicsModConfig::DeserializeFromProfile(const picojson::object& obj)
} }
} }
} }
bool GraphicsModConfig::operator<(const GraphicsModConfig& other) const
{
return m_weight < other.m_weight;
}

View File

@ -43,6 +43,4 @@ struct GraphicsModConfig
void SerializeToProfile(picojson::object* value) const; void SerializeToProfile(picojson::object* value) const;
void DeserializeFromProfile(const picojson::object& value); void DeserializeFromProfile(const picojson::object& value);
bool operator<(const GraphicsModConfig& other) const;
}; };

View File

@ -111,7 +111,7 @@ void GraphicsModGroupConfig::Load()
try_add_mod(graphics_mod_directory, GraphicsModConfig::Source::System); try_add_mod(graphics_mod_directory, GraphicsModConfig::Source::System);
} }
std::sort(m_graphics_mods.begin(), m_graphics_mods.end()); std::ranges::sort(m_graphics_mods, {}, &GraphicsModConfig::m_weight);
for (auto& mod : m_graphics_mods) for (auto& mod : m_graphics_mods)
{ {
m_path_to_graphics_mod[mod.GetAbsolutePath()] = &mod; m_path_to_graphics_mod[mod.GetAbsolutePath()] = &mod;