Modernize std::max_element with ranges and projections

This commit is contained in:
mitaclaw 2024-09-29 11:13:02 -07:00
parent 41c04ded93
commit 8a3b380ded
2 changed files with 3 additions and 8 deletions

View File

@ -1538,9 +1538,7 @@ void NetPlayClient::DisplayPlayersPing()
u32 NetPlayClient::GetPlayersMaxPing() const
{
return std::max_element(
m_players.begin(), m_players.end(),
[](const auto& a, const auto& b) { return a.second.ping < b.second.ping; })
return std::ranges::max_element(m_players, {}, [](const auto& kv) { return kv.second.ping; })
->second.ping;
}

View File

@ -1667,11 +1667,8 @@ RcTcacheEntry TextureCacheBase::CreateTextureEntry(
if (!assets_data.empty())
{
const auto calculate_max_levels = [&]() {
const auto max_element = std::max_element(
assets_data.begin(), assets_data.end(), [](const auto& lhs, const auto& rhs) {
return lhs->m_texture.m_slices[0].m_levels.size() <
rhs->m_texture.m_slices[0].m_levels.size();
});
const auto max_element = std::ranges::max_element(
assets_data, {}, [](const auto& v) { return v->m_texture.m_slices[0].m_levels.size(); });
return (*max_element)->m_texture.m_slices[0].m_levels.size();
};
const u32 texLevels = no_mips ? 1 : (u32)calculate_max_levels();