mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Modernize std::all_of
with ranges
In DITSpecification.cpp, MaterialAsset.cpp, and ShaderAsset.cpp, lambda predicates were replaced by pointers to member functions because ranges algorithms are able invoke those. In NetPlayClient.cpp, the non-trivial `NetPlay::Player` elements were being passed by value in `NetPlayClient::DoAllPlayersHaveGame()`. This has been fixed. In WIABlob.cpp, the second example's predicate was returning the `std::optional` by value instead of implicitly converting it to a bool. This has been fixed.
This commit is contained in:
@ -40,7 +40,7 @@ std::string NameForPartitionType(u32 partition_type, bool include_prefix)
|
||||
static_cast<char>((partition_type >> 16) & 0xFF),
|
||||
static_cast<char>((partition_type >> 8) & 0xFF),
|
||||
static_cast<char>(partition_type & 0xFF)};
|
||||
if (std::all_of(type_as_game_id.cbegin(), type_as_game_id.cend(), Common::IsAlnum))
|
||||
if (std::ranges::all_of(type_as_game_id, Common::IsAlnum))
|
||||
{
|
||||
return include_prefix ? "P-" + type_as_game_id : type_as_game_id;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ FileDataLoaderHostFS::MakeAbsoluteFromRelative(std::string_view external_relativ
|
||||
result.pop_back();
|
||||
result.pop_back();
|
||||
}
|
||||
else if (std::all_of(element.begin(), element.end(), [](char c) { return c == '.'; }))
|
||||
else if (std::ranges::all_of(element, [](char c) { return c == '.'; }))
|
||||
{
|
||||
// This is a triple, quadruple, etc. dot.
|
||||
// Some file systems treat this as several 'up' path traversals, but Riivolution does not.
|
||||
|
@ -176,7 +176,7 @@ IOS::ES::TicketReader VolumeWAD::GetTicketWithFixedCommonKey() const
|
||||
return m_ticket;
|
||||
|
||||
const std::vector<u8> sig = m_ticket.GetSignatureData();
|
||||
if (!std::all_of(sig.cbegin(), sig.cend(), [](u8 a) { return a == 0; }))
|
||||
if (!std::ranges::all_of(sig, [](u8 a) { return a == 0; }))
|
||||
{
|
||||
// This does not look like a typical "invalid common key index" ticket, so let's assume
|
||||
// the index is correct. This saves some time when reading properly signed titles.
|
||||
|
@ -1126,7 +1126,7 @@ bool WIARVZFileReader<RVZ>::TryReuse(std::map<ReuseID, GroupEntry>* reusable_gro
|
||||
|
||||
static bool AllAre(const std::vector<u8>& data, u8 x)
|
||||
{
|
||||
return std::all_of(data.begin(), data.end(), [x](u8 y) { return x == y; });
|
||||
return std::ranges::all_of(data, [x](u8 y) { return x == y; });
|
||||
}
|
||||
|
||||
static bool AllAre(const u8* begin, const u8* end, u8 x)
|
||||
@ -1379,8 +1379,8 @@ WIARVZFileReader<RVZ>::ProcessAndCompress(CompressThreadState* state, CompressPa
|
||||
}
|
||||
}
|
||||
|
||||
if (!std::all_of(output_entries.begin(), output_entries.end(),
|
||||
[](const OutputParametersEntry& entry) { return entry.reused_group; }))
|
||||
if (!std::ranges::all_of(output_entries,
|
||||
[](const auto& entry) { return entry.reused_group.has_value(); }))
|
||||
{
|
||||
const u64 number_of_exception_lists =
|
||||
chunks_per_wii_group == 1 ? exception_lists_per_chunk : chunks;
|
||||
|
Reference in New Issue
Block a user