mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-24 06:51:17 +01:00
Modernize std::sort
with ranges
This commit is contained in:
parent
bcaf665d14
commit
ebf7cebc32
@ -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 -
|
// 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
|
// not because std::filesystem returns duplicates). Also note that this pathname-based uniqueness
|
||||||
// isn't as thorough as std::filesystem::equivalent.
|
// 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());
|
result.erase(std::unique(result.begin(), result.end()), result.end());
|
||||||
|
|
||||||
// Dolphin expects to be able to use "/" (DIR_SEP) everywhere.
|
// Dolphin expects to be able to use "/" (DIR_SEP) everywhere.
|
||||||
|
@ -624,16 +624,15 @@ void DirectoryBlobReader::SetWiiRegionData(const std::vector<u8>& wii_region_dat
|
|||||||
|
|
||||||
void DirectoryBlobReader::SetPartitions(std::vector<PartitionWithType>&& partitions)
|
void DirectoryBlobReader::SetPartitions(std::vector<PartitionWithType>&& partitions)
|
||||||
{
|
{
|
||||||
std::sort(partitions.begin(), partitions.end(),
|
std::ranges::sort(partitions, [](const PartitionWithType& lhs, const PartitionWithType& rhs) {
|
||||||
[](const PartitionWithType& lhs, const PartitionWithType& rhs) {
|
if (lhs.type == rhs.type)
|
||||||
if (lhs.type == rhs.type)
|
return lhs.partition.GetRootDirectory() < rhs.partition.GetRootDirectory();
|
||||||
return lhs.partition.GetRootDirectory() < rhs.partition.GetRootDirectory();
|
|
||||||
|
|
||||||
// Ascending sort by partition type, except Update (1) comes before before Game (0)
|
// Ascending sort by partition type, except Update (1) comes before before Game (0)
|
||||||
return (lhs.type > PartitionType::Update || rhs.type > PartitionType::Update) ?
|
return (lhs.type > PartitionType::Update || rhs.type > PartitionType::Update) ?
|
||||||
lhs.type < rhs.type :
|
lhs.type < rhs.type :
|
||||||
lhs.type > rhs.type;
|
lhs.type > rhs.type;
|
||||||
});
|
});
|
||||||
|
|
||||||
u32 subtable_1_size = 0;
|
u32 subtable_1_size = 0;
|
||||||
while (subtable_1_size < partitions.size() && subtable_1_size < 3 &&
|
while (subtable_1_size < partitions.size() && subtable_1_size < 3 &&
|
||||||
|
@ -481,7 +481,7 @@ void WatchWidget::DeleteSelectedWatches()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sort greatest to smallest, so we don't stomp on existing indices
|
// 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)
|
for (const int row : row_indices)
|
||||||
{
|
{
|
||||||
DeleteWatch(guard, row);
|
DeleteWatch(guard, row);
|
||||||
|
@ -101,7 +101,7 @@ BuildExpression(const std::vector<ciface::Core::DeviceContainer::InputDetection>
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::sort(alternation.begin(), alternation.end());
|
std::ranges::sort(alternation);
|
||||||
alternations.push_back(fmt::to_string(fmt::join(alternation, "&")));
|
alternations.push_back(fmt::to_string(fmt::join(alternation, "&")));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -128,7 +128,7 @@ BuildExpression(const std::vector<ciface::Core::DeviceContainer::InputDetection>
|
|||||||
handle_release();
|
handle_release();
|
||||||
|
|
||||||
// Remove duplicates
|
// Remove duplicates
|
||||||
std::sort(alternations.begin(), alternations.end());
|
std::ranges::sort(alternations);
|
||||||
alternations.erase(std::unique(alternations.begin(), alternations.end()), alternations.end());
|
alternations.erase(std::unique(alternations.begin(), alternations.end()), alternations.end());
|
||||||
|
|
||||||
return fmt::to_string(fmt::join(alternations, "|"));
|
return fmt::to_string(fmt::join(alternations, "|"));
|
||||||
|
@ -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); };
|
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
|
ScissorRect ScissorResult::Best() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user