summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authormitaclaw <140017135+mitaclaw@users.noreply.github.com>2024-09-29 11:19:05 -0700
committermitaclaw <140017135+mitaclaw@users.noreply.github.com>2024-10-10 00:53:48 -0700
commitebf7cebc32ac9af28dc2383192b7b14f7aea134f (patch)
tree792a436fe69984534ba5cc17544ad16722ce4e80 /Source
parentbcaf665d14c5e20ecc88a8978df19ca73e0e29fc (diff)
Modernize `std::sort` with ranges
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Common/FileSearch.cpp2
-rw-r--r--Source/Core/DiscIO/DirectoryBlob.cpp19
-rw-r--r--Source/Core/DolphinQt/Debugger/WatchWidget.cpp2
-rw-r--r--Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp4
-rw-r--r--Source/Core/VideoCommon/BPFunctions.cpp2
5 files changed, 14 insertions, 15 deletions
diff --git a/Source/Core/Common/FileSearch.cpp b/Source/Core/Common/FileSearch.cpp
index 31b5e3cd37..4a54c978c9 100644
--- a/Source/Core/Common/FileSearch.cpp
+++ b/Source/Core/Common/FileSearch.cpp
@@ -97,7 +97,7 @@ std::vector<std::string> DoFileSearch(const std::vector<std::string>& directorie
// Remove duplicates (occurring because caller gave e.g. duplicate or overlapping directories -
// not because std::filesystem returns duplicates). Also note that this pathname-based uniqueness
// isn't as thorough as std::filesystem::equivalent.
- std::sort(result.begin(), result.end());
+ std::ranges::sort(result);
result.erase(std::unique(result.begin(), result.end()), result.end());
// Dolphin expects to be able to use "/" (DIR_SEP) everywhere.
diff --git a/Source/Core/DiscIO/DirectoryBlob.cpp b/Source/Core/DiscIO/DirectoryBlob.cpp
index 7cd7e12def..b9e8b89dd4 100644
--- a/Source/Core/DiscIO/DirectoryBlob.cpp
+++ b/Source/Core/DiscIO/DirectoryBlob.cpp
@@ -624,16 +624,15 @@ void DirectoryBlobReader::SetWiiRegionData(const std::vector<u8>& wii_region_dat
void DirectoryBlobReader::SetPartitions(std::vector<PartitionWithType>&& partitions)
{
- std::sort(partitions.begin(), partitions.end(),
- [](const PartitionWithType& lhs, const PartitionWithType& rhs) {
- if (lhs.type == rhs.type)
- return lhs.partition.GetRootDirectory() < rhs.partition.GetRootDirectory();
-
- // Ascending sort by partition type, except Update (1) comes before before Game (0)
- return (lhs.type > PartitionType::Update || rhs.type > PartitionType::Update) ?
- lhs.type < rhs.type :
- lhs.type > rhs.type;
- });
+ std::ranges::sort(partitions, [](const PartitionWithType& lhs, const PartitionWithType& rhs) {
+ if (lhs.type == rhs.type)
+ return lhs.partition.GetRootDirectory() < rhs.partition.GetRootDirectory();
+
+ // Ascending sort by partition type, except Update (1) comes before before Game (0)
+ return (lhs.type > PartitionType::Update || rhs.type > PartitionType::Update) ?
+ lhs.type < rhs.type :
+ lhs.type > rhs.type;
+ });
u32 subtable_1_size = 0;
while (subtable_1_size < partitions.size() && subtable_1_size < 3 &&
diff --git a/Source/Core/DolphinQt/Debugger/WatchWidget.cpp b/Source/Core/DolphinQt/Debugger/WatchWidget.cpp
index 170bfcc792..7cc61d1334 100644
--- a/Source/Core/DolphinQt/Debugger/WatchWidget.cpp
+++ b/Source/Core/DolphinQt/Debugger/WatchWidget.cpp
@@ -481,7 +481,7 @@ void WatchWidget::DeleteSelectedWatches()
}
// Sort greatest to smallest, so we don't stomp on existing indices
- std::sort(row_indices.begin(), row_indices.end(), std::greater{});
+ std::ranges::sort(row_indices, std::ranges::greater{});
for (const int row : row_indices)
{
DeleteWatch(guard, row);
diff --git a/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp b/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp
index 4acee6a970..1877e8294c 100644
--- a/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/MappingCommon.cpp
@@ -101,7 +101,7 @@ BuildExpression(const std::vector<ciface::Core::DeviceContainer::InputDetection>
}
else
{
- std::sort(alternation.begin(), alternation.end());
+ std::ranges::sort(alternation);
alternations.push_back(fmt::to_string(fmt::join(alternation, "&")));
}
};
@@ -128,7 +128,7 @@ BuildExpression(const std::vector<ciface::Core::DeviceContainer::InputDetection>
handle_release();
// Remove duplicates
- std::sort(alternations.begin(), alternations.end());
+ std::ranges::sort(alternations);
alternations.erase(std::unique(alternations.begin(), alternations.end()), alternations.end());
return fmt::to_string(fmt::join(alternations, "|"));
diff --git a/Source/Core/VideoCommon/BPFunctions.cpp b/Source/Core/VideoCommon/BPFunctions.cpp
index ecb045e6ad..2c6c733710 100644
--- a/Source/Core/VideoCommon/BPFunctions.cpp
+++ b/Source/Core/VideoCommon/BPFunctions.cpp
@@ -151,7 +151,7 @@ ScissorResult::ScissorResult(const BPMemory& bpmemory, std::pair<float, float> v
}
auto cmp = [&](const ScissorRect& lhs, const ScissorRect& rhs) { return IsWorse(lhs, rhs); };
- std::sort(m_result.begin(), m_result.end(), cmp);
+ std::ranges::sort(m_result, cmp);
}
ScissorRect ScissorResult::Best() const