From 8b9f92a0af0f467ffa0bde5f4e6239e57fbd4b5e Mon Sep 17 00:00:00 2001 From: mitaclaw <140017135+mitaclaw@users.noreply.github.com> Date: Sun, 29 Sep 2024 11:19:33 -0700 Subject: Modernize `std::sort` with ranges and projections In PPCTables.cpp, the code is currently unused so I was unable to test it. In CustomPipeline.cpp, a pointer to member function cannot be used due to 16.4.5.2.1 of the C++ Standard regarding "addressable functions". https://eel.is/c++draft/namespace.std#6 In Fs.cpp and DirectoryBlob.cpp, these examples used projections in a previous iteration of this commit, but no longer do. Still, they remain in this commit because the PR they would actually belong to is already merged. --- Source/Core/VideoCommon/TextureCacheBase.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 61882476d7..70a753931a 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -2026,8 +2026,7 @@ void TextureCacheBase::StitchXFBCopy(RcTcacheEntry& stitched_entry) if (candidates.empty()) return; - std::sort(candidates.begin(), candidates.end(), - [](const TCacheEntry* a, const TCacheEntry* b) { return a->id < b->id; }); + std::ranges::sort(candidates, {}, &TCacheEntry::id); // We only upscale when necessary to preserve resolution. i.e. when there are upscaled partial // copies to be stitched together. -- cgit v1.2.3 From e4efe011d71b668537bc551996848e911de079ab 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: Modernize `std::max_element` with ranges and projections --- Source/Core/VideoCommon/TextureCacheBase.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 70a753931a..57c07f7675 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -1665,11 +1665,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(); -- cgit v1.2.3