summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authormitaclaw <140017135+mitaclaw@users.noreply.github.com>2024-09-29 11:19:33 -0700
committermitaclaw <140017135+mitaclaw@users.noreply.github.com>2025-03-09 13:26:38 -0700
commit8b9f92a0af0f467ffa0bde5f4e6239e57fbd4b5e (patch)
tree094c6bc6d9007cbf96cdaac54dbdc3cc8e24e320 /Source/Core/VideoCommon
parent9f972db4b8e730751d643680ec90f177c3010333 (diff)
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.
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp6
-rw-r--r--Source/Core/VideoCommon/TextureCacheBase.cpp3
2 files changed, 3 insertions, 6 deletions
diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp
index 0001a9081d..b52df66e31 100644
--- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp
+++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomPipeline.cpp
@@ -165,10 +165,8 @@ std::vector<std::string> GlobalConflicts(std::string_view source)
// Sort the conflicts from largest to smallest string
// this way we can ensure smaller strings that are a substring
// of the larger string are able to be replaced appropriately
- std::sort(global_result.begin(), global_result.end(),
- [](const std::string& first, const std::string& second) {
- return first.size() > second.size();
- });
+ std::ranges::sort(global_result, std::ranges::greater{},
+ [](const std::string& s) { return s.size(); });
return global_result;
}
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.