mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 21:30:19 -06:00
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.
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user