From 8a3b380ded370062f3285d7013b00be05a617232 Mon Sep 17 00:00:00 2001 From: mitaclaw <140017135+mitaclaw@users.noreply.github.com> Date: Sun, 29 Sep 2024 11:13:02 -0700 Subject: [PATCH] Modernize `std::max_element` with ranges and projections --- Source/Core/Core/NetPlayClient.cpp | 4 +--- Source/Core/VideoCommon/TextureCacheBase.cpp | 7 ++----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index 415dc4af99..2d798ce7ff 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -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; } diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 5ae7d6c059..6fc146e086 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -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();