mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 05:40:01 -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:
@ -1192,15 +1192,13 @@ void DirectoryBlobPartition::WriteDirectory(std::vector<u8>* fst_data,
|
||||
std::vector<FSTBuilderNode>& sorted_entries = *parent_entries;
|
||||
|
||||
// Sort for determinism
|
||||
std::sort(sorted_entries.begin(), sorted_entries.end(),
|
||||
[](const FSTBuilderNode& one, const FSTBuilderNode& two) {
|
||||
std::string one_upper = one.m_filename;
|
||||
std::string two_upper = two.m_filename;
|
||||
Common::ToUpper(&one_upper);
|
||||
Common::ToUpper(&two_upper);
|
||||
return one_upper == two_upper ? one.m_filename < two.m_filename :
|
||||
one_upper < two_upper;
|
||||
});
|
||||
std::ranges::sort(sorted_entries, [](const FSTBuilderNode& one, const FSTBuilderNode& two) {
|
||||
std::string one_upper = one.m_filename;
|
||||
std::string two_upper = two.m_filename;
|
||||
Common::ToUpper(&one_upper);
|
||||
Common::ToUpper(&two_upper);
|
||||
return one_upper == two_upper ? one.m_filename < two.m_filename : one_upper < two_upper;
|
||||
});
|
||||
|
||||
for (FSTBuilderNode& entry : sorted_entries)
|
||||
{
|
||||
|
Reference in New Issue
Block a user