Modernize std::any_of with ranges

In WiimoteReal.cpp, JitRegCache.cpp, lambda predicates were replaced by pointers to member functions because ranges algorithms are able invoke those.

In ConvertDialog.cpp, the `std::mem_fn` helper was removed because ranges algorithms are able to handle pointers to member functions as predicates.
This commit is contained in:
mitaclaw 2024-09-30 17:26:50 -07:00
parent 860e6cf5cb
commit 140252ffc0
34 changed files with 69 additions and 82 deletions

View File

@ -91,7 +91,7 @@ void MemoryPatches::DisablePatch(const Core::CPUThreadGuard& guard, std::size_t
bool MemoryPatches::HasEnabledPatch(u32 address) const bool MemoryPatches::HasEnabledPatch(u32 address) const
{ {
return std::any_of(m_patches.begin(), m_patches.end(), [address](const MemoryPatch& patch) { return std::ranges::any_of(m_patches, [address](const MemoryPatch& patch) {
return patch.address == address && patch.is_enabled == MemoryPatch::State::Enabled; return patch.address == address && patch.is_enabled == MemoryPatch::State::Enabled;
}); });
} }

View File

@ -79,7 +79,7 @@ void Watches::DisableWatch(std::size_t index)
bool Watches::HasEnabledWatch(u32 address) const bool Watches::HasEnabledWatch(u32 address) const
{ {
return std::any_of(m_watches.begin(), m_watches.end(), [address](const auto& watch) { return std::ranges::any_of(m_watches, [address](const auto& watch) {
return watch.address == address && watch.is_enabled == Watch::State::Enabled; return watch.address == address && watch.is_enabled == Watch::State::Enabled;
}); });
} }

View File

@ -41,7 +41,7 @@ std::vector<std::string> DoFileSearch(const std::vector<std::string>& directorie
// N.B. This avoids doing any copies // N.B. This avoids doing any copies
auto ext_matches = [&native_exts](const fs::path& path) { auto ext_matches = [&native_exts](const fs::path& path) {
const std::basic_string_view<fs::path::value_type> native_path = path.native(); const std::basic_string_view<fs::path::value_type> native_path = path.native();
return std::any_of(native_exts.cbegin(), native_exts.cend(), [&native_path](const auto& ext) { return std::ranges::any_of(native_exts, [&native_path](const auto& ext) {
const auto compare_len = ext.native().length(); const auto compare_len = ext.native().length();
if (native_path.length() < compare_len) if (native_path.length() < compare_len)
return false; return false;

View File

@ -114,9 +114,8 @@ public:
for (const auto& value : section_map) for (const auto& value : section_map)
{ {
const Config::Location location{system.first, section_name, value.first}; const Config::Location location{system.first, section_name, value.first};
const bool load_disallowed = const bool load_disallowed = std::ranges::any_of(
std::any_of(begin(s_setting_disallowed), end(s_setting_disallowed), s_setting_disallowed, [&location](const auto* l) { return *l == location; });
[&location](const Config::Location* l) { return *l == location; });
if (load_disallowed) if (load_disallowed)
continue; continue;

View File

@ -27,9 +27,8 @@ bool IsSettingSaveable(const Config::Location& config_location)
&Config::WIIMOTE_BB_SOURCE.GetLocation(), &Config::WIIMOTE_BB_SOURCE.GetLocation(),
}; };
return std::any_of(begin(s_setting_saveable), end(s_setting_saveable), return std::ranges::any_of(s_setting_saveable, [&config_location](const auto* location) {
[&config_location](const Config::Location* location) { return *location == config_location;
return *location == config_location; });
});
} }
} // namespace ConfigLoaders } // namespace ConfigLoaders

View File

@ -267,8 +267,8 @@ HitType CodeTrace::TraceLogic(const TraceOutput& current_instr, bool first_hit)
// Checks if the intstruction is a type that needs special handling. // Checks if the intstruction is a type that needs special handling.
const auto CompareInstruction = [](std::string_view instruction, const auto& type_compare) { const auto CompareInstruction = [](std::string_view instruction, const auto& type_compare) {
return std::any_of(type_compare.begin(), type_compare.end(), return std::ranges::any_of(
[&instruction](std::string_view s) { return instruction.starts_with(s); }); type_compare, [&instruction](std::string_view s) { return instruction.starts_with(s); });
}; };
// Exclusions from updating tracking logic. mt operations are too complex and specialized. // Exclusions from updating tracking logic. mt operations are too complex and specialized.

View File

@ -101,8 +101,8 @@ std::pair<GCMemcardErrorCode, std::optional<GCMemcard>> GCMemcard::Open(std::str
MBIT_SIZE_MEMORY_CARD_2043, MBIT_SIZE_MEMORY_CARD_2043,
}}; }};
if (!std::any_of(valid_megabits.begin(), valid_megabits.end(), if (!std::ranges::any_of(valid_megabits,
[filesize_megabits](u64 mbits) { return mbits == filesize_megabits; })) [filesize_megabits](u64 mbits) { return mbits == filesize_megabits; }))
{ {
error_code.Set(GCMemcardValidityIssues::INVALID_CARD_SIZE); error_code.Set(GCMemcardValidityIssues::INVALID_CARD_SIZE);
return std::make_pair(error_code, std::nullopt); return std::make_pair(error_code, std::nullopt);
@ -1296,8 +1296,8 @@ GCMemcardErrorCode Header::CheckForErrors(u16 card_size_mbits) const
error_code.Set(GCMemcardValidityIssues::MISMATCHED_CARD_SIZE); error_code.Set(GCMemcardValidityIssues::MISMATCHED_CARD_SIZE);
// unused areas, should always be filled with 0xFF // unused areas, should always be filled with 0xFF
if (std::any_of(m_unused_1.begin(), m_unused_1.end(), [](u8 val) { return val != 0xFF; }) || if (std::ranges::any_of(m_unused_1, [](u8 val) { return val != 0xFF; }) ||
std::any_of(m_unused_2.begin(), m_unused_2.end(), [](u8 val) { return val != 0xFF; })) std::ranges::any_of(m_unused_2, [](u8 val) { return val != 0xFF; }))
{ {
error_code.Set(GCMemcardValidityIssues::DATA_IN_UNUSED_AREA); error_code.Set(GCMemcardValidityIssues::DATA_IN_UNUSED_AREA);
} }
@ -1361,7 +1361,7 @@ GCMemcardErrorCode Directory::CheckForErrors() const
error_code.Set(GCMemcardValidityIssues::INVALID_CHECKSUM); error_code.Set(GCMemcardValidityIssues::INVALID_CHECKSUM);
// unused area, should always be filled with 0xFF // unused area, should always be filled with 0xFF
if (std::any_of(m_padding.begin(), m_padding.end(), [](u8 val) { return val != 0xFF; })) if (std::ranges::any_of(m_padding, [](u8 val) { return val != 0xFF; }))
error_code.Set(GCMemcardValidityIssues::DATA_IN_UNUSED_AREA); error_code.Set(GCMemcardValidityIssues::DATA_IN_UNUSED_AREA);
return error_code; return error_code;

View File

@ -613,8 +613,7 @@ void WiimoteScanner::SetScanMode(WiimoteScanMode scan_mode)
bool WiimoteScanner::IsReady() const bool WiimoteScanner::IsReady() const
{ {
std::lock_guard lg(m_backends_mutex); std::lock_guard lg(m_backends_mutex);
return std::any_of(m_backends.begin(), m_backends.end(), return std::ranges::any_of(m_backends, &WiimoteScannerBackend::IsReady);
[](const auto& backend) { return backend->IsReady(); });
} }
static void CheckForDisconnectedWiimotes() static void CheckForDisconnectedWiimotes()

View File

@ -878,7 +878,7 @@ ReturnCode ESCore::DeleteSharedContent(const std::array<u8, 20>& sha1) const
// Check whether the shared content is used by a system title. // Check whether the shared content is used by a system title.
const std::vector<u64> titles = GetInstalledTitles(); const std::vector<u64> titles = GetInstalledTitles();
const bool is_used_by_system_title = std::any_of(titles.begin(), titles.end(), [&](u64 id) { const bool is_used_by_system_title = std::ranges::any_of(titles, [&](u64 id) {
if (!ES::IsTitleType(id, ES::TitleType::System)) if (!ES::IsTitleType(id, ES::TitleType::System))
return false; return false;
@ -887,8 +887,8 @@ ReturnCode ESCore::DeleteSharedContent(const std::array<u8, 20>& sha1) const
return true; return true;
const auto contents = tmd.GetContents(); const auto contents = tmd.GetContents();
return std::any_of(contents.begin(), contents.end(), return std::ranges::any_of(contents,
[&sha1](const auto& content) { return content.sha1 == sha1; }); [&sha1](const auto& content) { return content.sha1 == sha1; });
}); });
// Any shared content used by a system title cannot be deleted. // Any shared content used by a system title cannot be deleted.

View File

@ -26,7 +26,7 @@ bool IsValidNonRootPath(std::string_view path)
bool IsValidFilename(std::string_view filename) bool IsValidFilename(std::string_view filename)
{ {
return filename.length() <= MaxFilenameLength && return filename.length() <= MaxFilenameLength &&
!std::any_of(filename.begin(), filename.end(), [](char c) { return c == '/'; }); !std::ranges::any_of(filename, [](char c) { return c == '/'; });
} }
SplitPathResult SplitPathAndBasename(std::string_view path) SplitPathResult SplitPathAndBasename(std::string_view path)

View File

@ -515,14 +515,14 @@ ResultCode HostFileSystem::CreateDirectory(Uid uid, Gid gid, const std::string&
bool HostFileSystem::IsFileOpened(const std::string& path) const bool HostFileSystem::IsFileOpened(const std::string& path) const
{ {
return std::any_of(m_handles.begin(), m_handles.end(), [&path](const Handle& handle) { return std::ranges::any_of(m_handles, [&path](const Handle& handle) {
return handle.opened && handle.wii_path == path; return handle.opened && handle.wii_path == path;
}); });
} }
bool HostFileSystem::IsDirectoryInUse(const std::string& path) const bool HostFileSystem::IsDirectoryInUse(const std::string& path) const
{ {
return std::any_of(m_handles.begin(), m_handles.end(), [&path](const Handle& handle) { return std::ranges::any_of(m_handles, [&path](const Handle& handle) {
return handle.opened && handle.wii_path.starts_with(path); return handle.opened && handle.wii_path.starts_with(path);
}); });
} }

View File

@ -58,8 +58,8 @@ bool WC24FriendList::CheckFriendList() const
bool WC24FriendList::DoesFriendExist(u64 friend_id) const bool WC24FriendList::DoesFriendExist(u64 friend_id) const
{ {
return std::any_of(m_data.friend_codes.cbegin(), m_data.friend_codes.cend(), return std::ranges::any_of(m_data.friend_codes,
[&friend_id](const u64 v) { return v == friend_id; }); [&friend_id](const u64 v) { return v == friend_id; });
} }
std::vector<u64> WC24FriendList::GetUnconfirmedFriends() const std::vector<u64> WC24FriendList::GetUnconfirmedFriends() const

View File

@ -74,7 +74,7 @@ bool Device::HasClass(const u8 device_class) const
if (GetDeviceDescriptor().bDeviceClass == device_class) if (GetDeviceDescriptor().bDeviceClass == device_class)
return true; return true;
const auto interfaces = GetInterfaces(0); const auto interfaces = GetInterfaces(0);
return std::any_of(interfaces.begin(), interfaces.end(), [device_class](const auto& interface) { return std::ranges::any_of(interfaces, [device_class](const auto& interface) {
return interface.bInterfaceClass == device_class; return interface.bInterfaceClass == device_class;
}); });
} }

View File

@ -234,7 +234,7 @@ std::optional<IPCReply> OH0::RegisterClassChangeHook(const IOCtlVRequest& reques
bool OH0::HasDeviceWithVidPid(const u16 vid, const u16 pid) const bool OH0::HasDeviceWithVidPid(const u16 vid, const u16 pid) const
{ {
return std::any_of(m_devices.begin(), m_devices.end(), [=](const auto& device) { return std::ranges::any_of(m_devices, [=](const auto& device) {
return device.second->GetVid() == vid && device.second->GetPid() == pid; return device.second->GetVid() == vid && device.second->GetPid() == pid;
}); });
} }

View File

@ -380,9 +380,9 @@ bool IsEmulated(u32 major_version)
if (major_version == static_cast<u32>(Titles::BC & 0xffffffff)) if (major_version == static_cast<u32>(Titles::BC & 0xffffffff))
return true; return true;
return std::any_of( return std::ranges::any_of(ios_memory_values, [major_version](const MemoryValues& values) {
ios_memory_values.begin(), ios_memory_values.end(), return values.ios_number == major_version;
[major_version](const MemoryValues& values) { return values.ios_number == major_version; }); });
} }
bool IsEmulated(u64 title_id) bool IsEmulated(u64 title_id)

View File

@ -375,8 +375,8 @@ s32 WFSSRVDevice::Rename(std::string source, std::string dest) const
INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_RENAME: {} to {}", source, dest); INFO_LOG_FMT(IOS_WFS, "IOCTL_WFS_RENAME: {} to {}", source, dest);
const bool opened = std::any_of(m_fds.begin(), m_fds.end(), const bool opened =
[&](const auto& fd) { return fd.in_use && fd.path == source; }); std::ranges::any_of(m_fds, [&](const auto& fd) { return fd.in_use && fd.path == source; });
if (opened) if (opened)
return WFS_FILE_IS_OPENED; return WFS_FILE_IS_OPENED;

View File

@ -2486,8 +2486,8 @@ bool NetPlayClient::PlayerHasControllerMapped(const PlayerId pid) const
{ {
const auto mapping_matches_player_id = [pid](const PlayerId& mapping) { return mapping == pid; }; const auto mapping_matches_player_id = [pid](const PlayerId& mapping) { return mapping == pid; };
return std::any_of(m_pad_map.begin(), m_pad_map.end(), mapping_matches_player_id) || return std::ranges::any_of(m_pad_map, mapping_matches_player_id) ||
std::any_of(m_wiimote_map.begin(), m_wiimote_map.end(), mapping_matches_player_id); std::ranges::any_of(m_wiimote_map, mapping_matches_player_id);
} }
bool NetPlayClient::IsLocalPlayer(const PlayerId pid) const bool NetPlayClient::IsLocalPlayer(const PlayerId pid) const

View File

@ -2232,8 +2232,8 @@ bool NetPlayServer::PlayerHasControllerMapped(const PlayerId pid) const
{ {
const auto mapping_matches_player_id = [pid](const PlayerId& mapping) { return mapping == pid; }; const auto mapping_matches_player_id = [pid](const PlayerId& mapping) { return mapping == pid; };
return std::any_of(m_pad_map.begin(), m_pad_map.end(), mapping_matches_player_id) || return std::ranges::any_of(m_pad_map, mapping_matches_player_id) ||
std::any_of(m_wiimote_map.begin(), m_wiimote_map.end(), mapping_matches_player_id); std::ranges::any_of(m_wiimote_map, mapping_matches_player_id);
} }
void NetPlayServer::AssignNewUserAPad(const Client& player) void NetPlayServer::AssignNewUserAPad(const Client& player)

View File

@ -371,7 +371,7 @@ bool MemChecks::OverlapsMemcheck(u32 address, u32 length) const
const u32 page_end_suffix = length - 1; const u32 page_end_suffix = length - 1;
const u32 page_end_address = address | page_end_suffix; const u32 page_end_address = address | page_end_suffix;
return std::any_of(m_mem_checks.cbegin(), m_mem_checks.cend(), [&](const auto& mc) { return std::ranges::any_of(m_mem_checks, [&](const auto& mc) {
return ((mc.start_address | page_end_suffix) == page_end_address || return ((mc.start_address | page_end_suffix) == page_end_address ||
(mc.end_address | page_end_suffix) == page_end_address) || (mc.end_address | page_end_suffix) == page_end_address) ||
((mc.start_address | page_end_suffix) < page_end_address && ((mc.start_address | page_end_suffix) < page_end_address &&

View File

@ -136,15 +136,14 @@ static double CallstackFunc(expr_func* f, vec_expr_t* args, void* c)
if (!std::isnan(num)) if (!std::isnan(num))
{ {
u32 address = static_cast<u32>(num); u32 address = static_cast<u32>(num);
return std::any_of(stack.begin(), stack.end(), return std::ranges::any_of(stack, [address](const auto& s) { return s.vAddress == address; });
[address](const auto& s) { return s.vAddress == address; });
} }
const char* cstr = expr_get_str(&vec_nth(args, 0)); const char* cstr = expr_get_str(&vec_nth(args, 0));
if (cstr != nullptr) if (cstr != nullptr)
{ {
return std::any_of(stack.begin(), stack.end(), return std::ranges::any_of(
[cstr](const auto& s) { return s.Name.find(cstr) != std::string::npos; }); stack, [cstr](const auto& s) { return s.Name.find(cstr) != std::string::npos; });
} }
return 0; return 0;

View File

@ -754,6 +754,5 @@ void RegCache::Realize(preg_t preg)
bool RegCache::IsAnyConstraintActive() const bool RegCache::IsAnyConstraintActive() const
{ {
return std::any_of(m_constraints.begin(), m_constraints.end(), return std::ranges::any_of(m_constraints, &RCConstraint::IsActive);
[](const auto& c) { return c.IsActive(); });
} }

View File

@ -112,7 +112,7 @@ JitBase::~JitBase()
bool JitBase::DoesConfigNeedRefresh() bool JitBase::DoesConfigNeedRefresh()
{ {
return std::any_of(JIT_SETTINGS.begin(), JIT_SETTINGS.end(), [this](const auto& pair) { return std::ranges::any_of(JIT_SETTINGS, [this](const auto& pair) {
return this->*pair.first != Config::Get(*pair.second); return this->*pair.first != Config::Get(*pair.second);
}); });
} }

View File

@ -191,7 +191,7 @@ static void AnalyzeFunction2(PPCSymbolDB* func_db, Common::Symbol* func)
{ {
u32 flags = func->flags; u32 flags = func->flags;
bool nonleafcall = std::any_of(func->calls.begin(), func->calls.end(), [&](const auto& call) { bool nonleafcall = std::ranges::any_of(func->calls, [&](const auto& call) {
const Common::Symbol* const called_func = func_db->GetSymbolFromAddr(call.function); const Common::Symbol* const called_func = func_db->GetSymbolFromAddr(call.function);
return called_func && (called_func->flags & Common::FFLAG_LEAF) == 0; return called_func && (called_func->flags & Common::FFLAG_LEAF) == 0;
}); });

View File

@ -223,15 +223,14 @@ bool IsTitleInstalled(u64 title_id)
// Since this isn't IOS and we only need a simple way to figure out if a title is installed, // Since this isn't IOS and we only need a simple way to figure out if a title is installed,
// we make the (reasonable) assumption that having more than just the TMD in the content // we make the (reasonable) assumption that having more than just the TMD in the content
// directory means that the title is installed. // directory means that the title is installed.
return std::any_of(entries->begin(), entries->end(), return std::ranges::any_of(*entries, [](const std::string& file) { return file != "title.tmd"; });
[](const std::string& file) { return file != "title.tmd"; });
} }
bool IsTMDImported(IOS::HLE::FS::FileSystem& fs, u64 title_id) bool IsTMDImported(IOS::HLE::FS::FileSystem& fs, u64 title_id)
{ {
const auto entries = fs.ReadDirectory(0, 0, Common::GetTitleContentPath(title_id)); const auto entries = fs.ReadDirectory(0, 0, Common::GetTitleContentPath(title_id));
return entries && std::any_of(entries->begin(), entries->end(), return entries &&
[](const std::string& file) { return file == "title.tmd"; }); std::ranges::any_of(*entries, [](const std::string& file) { return file == "title.tmd"; });
} }
IOS::ES::TMDReader FindBackupTMD(IOS::HLE::FS::FileSystem& fs, u64 title_id) IOS::ES::TMDReader FindBackupTMD(IOS::HLE::FS::FileSystem& fs, u64 title_id)
@ -947,8 +946,8 @@ static NANDCheckResult CheckNAND(IOS::HLE::Kernel& ios, bool repair)
} }
const auto installed_contents = es.GetStoredContentsFromTMD(tmd); const auto installed_contents = es.GetStoredContentsFromTMD(tmd);
const bool is_installed = std::any_of(installed_contents.begin(), installed_contents.end(), const bool is_installed = std::ranges::any_of(
[](const auto& content) { return !content.IsShared(); }); installed_contents, [](const auto& content) { return !content.IsShared(); });
if (is_installed && installed_contents != tmd.GetContents() && if (is_installed && installed_contents != tmd.GetContents() &&
(tmd.GetTitleFlags() & IOS::ES::TitleFlags::TITLE_TYPE_DATA) == 0) (tmd.GetTitleFlags() & IOS::ES::TitleFlags::TITLE_TYPE_DATA) == 0)

View File

@ -729,16 +729,15 @@ bool VolumeVerifier::ShouldHaveInstallPartition() const
static constexpr std::array<std::string_view, 4> dragon_quest_x = {"S4MJGD", "S4SJGD", "S6TJGD", static constexpr std::array<std::string_view, 4> dragon_quest_x = {"S4MJGD", "S4SJGD", "S6TJGD",
"SDQJGD"}; "SDQJGD"};
const std::string& game_id = m_volume.GetGameID(); const std::string& game_id = m_volume.GetGameID();
return std::any_of(dragon_quest_x.cbegin(), dragon_quest_x.cend(), return std::ranges::any_of(dragon_quest_x,
[&game_id](std::string_view x) { return x == game_id; }); [&game_id](std::string_view x) { return x == game_id; });
} }
bool VolumeVerifier::ShouldHaveMasterpiecePartitions() const bool VolumeVerifier::ShouldHaveMasterpiecePartitions() const
{ {
static constexpr std::array<std::string_view, 4> ssbb = {"RSBE01", "RSBJ01", "RSBK01", "RSBP01"}; static constexpr std::array<std::string_view, 4> ssbb = {"RSBE01", "RSBJ01", "RSBK01", "RSBP01"};
const std::string& game_id = m_volume.GetGameID(); const std::string& game_id = m_volume.GetGameID();
return std::any_of(ssbb.cbegin(), ssbb.cend(), return std::ranges::any_of(ssbb, [&game_id](std::string_view x) { return x == game_id; });
[&game_id](std::string_view x) { return x == game_id; });
} }
bool VolumeVerifier::ShouldBeDualLayer() const bool VolumeVerifier::ShouldBeDualLayer() const
@ -1039,7 +1038,7 @@ void VolumeVerifier::CheckSuperPaperMario()
if (!m_volume.Read(offset, length, data.data(), partition)) if (!m_volume.Read(offset, length, data.data(), partition))
return; return;
if (std::any_of(data.cbegin(), data.cend(), [](u8 x) { return x != 0; })) if (std::ranges::any_of(data, [](u8 x) { return x != 0; }))
{ {
AddProblem(Severity::High, AddProblem(Severity::High,
Common::GetStringT("Some padding data that should be zero is not zero. " Common::GetStringT("Some padding data that should be zero is not zero. "

View File

@ -598,9 +598,8 @@ void ShakeMappingIndicator::Update(float elapsed_seconds)
m_position_samples.push_front(ShakeSample{m_motion_state.position / MAX_DISTANCE}); m_position_samples.push_front(ShakeSample{m_motion_state.position / MAX_DISTANCE});
const bool any_non_zero_samples = const bool any_non_zero_samples = std::ranges::any_of(
std::any_of(m_position_samples.begin(), m_position_samples.end(), m_position_samples, [](const ShakeSample& s) { return s.state.LengthSquared() != 0.0; });
[](const ShakeSample& s) { return s.state.LengthSquared() != 0.0; });
// Only start moving the line if there's non-zero data. // Only start moving the line if there's non-zero data.
if (m_grid_line_position || any_non_zero_samples) if (m_grid_line_position || any_non_zero_samples)

View File

@ -309,7 +309,7 @@ void ConvertDialog::Convert()
} }
if (!scrub && format == DiscIO::BlobType::GCZ && if (!scrub && format == DiscIO::BlobType::GCZ &&
std::any_of(m_files.begin(), m_files.end(), [](const auto& file) { std::ranges::any_of(m_files, [](const auto& file) {
return file->GetPlatform() == DiscIO::Platform::WiiDisc && !file->IsDatelDisc(); return file->GetPlatform() == DiscIO::Platform::WiiDisc && !file->IsDatelDisc();
})) }))
{ {
@ -321,7 +321,7 @@ void ConvertDialog::Convert()
} }
} }
if (std::any_of(m_files.begin(), m_files.end(), std::mem_fn(&UICommon::GameFile::IsNKit))) if (std::ranges::any_of(m_files, &UICommon::GameFile::IsNKit))
{ {
if (!ShowAreYouSureDialog( if (!ShowAreYouSureDialog(
tr("Dolphin can't convert NKit files to non-NKit files. Converting an NKit file in " tr("Dolphin can't convert NKit files to non-NKit files. Converting an NKit file in "

View File

@ -428,8 +428,7 @@ void AudioPane::OnVolumeChanged(int volume)
void AudioPane::CheckNeedForLatencyControl() void AudioPane::CheckNeedForLatencyControl()
{ {
std::vector<std::string> backends = AudioCommon::GetSoundBackends(); std::vector<std::string> backends = AudioCommon::GetSoundBackends();
m_latency_control_supported = m_latency_control_supported = std::ranges::any_of(backends, AudioCommon::SupportsLatencyControl);
std::any_of(backends.cbegin(), backends.cend(), AudioCommon::SupportsLatencyControl);
} }
QString AudioPane::GetDPL2QualityLabel(AudioCommon::DPL2Quality value) const QString AudioPane::GetDPL2QualityLabel(AudioCommon::DPL2Quality value) const

View File

@ -90,8 +90,8 @@ void IMUGyroscope::UpdateCalibration(const StateData& state)
// Check for required calibration update frequency // Check for required calibration update frequency
// and if current data is within deadzone distance of mean stable value. // and if current data is within deadzone distance of mean stable value.
if (calibration_freq < WORST_ACCEPTABLE_CALIBRATION_UPDATE_FREQUENCY || if (calibration_freq < WORST_ACCEPTABLE_CALIBRATION_UPDATE_FREQUENCY ||
std::any_of(current_difference.data.begin(), current_difference.data.end(), std::ranges::any_of(current_difference.data,
[&](auto c) { return std::abs(c) > deadzone; })) [&](auto c) { return std::abs(c) > deadzone; }))
{ {
RestartCalibration(); RestartCalibration();
} }

View File

@ -248,7 +248,7 @@ bool ControllerInterface::AddDevice(std::shared_ptr<ciface::Core::Device> device
std::lock_guard lk(m_devices_mutex); std::lock_guard lk(m_devices_mutex);
const auto is_id_in_use = [&device, this](int id) { const auto is_id_in_use = [&device, this](int id) {
return std::any_of(m_devices.begin(), m_devices.end(), [&device, &id](const auto& d) { return std::ranges::any_of(m_devices, [&device, &id](const auto& d) {
return d->GetSource() == device->GetSource() && d->GetName() == device->GetName() && return d->GetSource() == device->GetSource() && d->GetName() == device->GetName() &&
d->GetId() == id; d->GetId() == id;
}); });
@ -368,10 +368,8 @@ void ControllerInterface::UpdateInput()
if (devices_to_remove.size() > 0) if (devices_to_remove.size() > 0)
{ {
RemoveDevice([&](const ciface::Core::Device* device) { RemoveDevice([&](const ciface::Core::Device* device) {
return std::any_of(devices_to_remove.begin(), devices_to_remove.end(), return std::ranges::any_of(devices_to_remove,
[device](const std::weak_ptr<ciface::Core::Device>& d) { [device](const auto& d) { return d.lock().get() == device; });
return d.lock().get() == device;
});
}); });
} }
} }

View File

@ -137,8 +137,8 @@ BuildExpression(const std::vector<ciface::Core::DeviceContainer::InputDetection>
void RemoveSpuriousTriggerCombinations( void RemoveSpuriousTriggerCombinations(
std::vector<ciface::Core::DeviceContainer::InputDetection>* detections) std::vector<ciface::Core::DeviceContainer::InputDetection>* detections)
{ {
const auto is_spurious = [&](auto& detection) { const auto is_spurious = [&](const auto& detection) {
return std::any_of(detections->begin(), detections->end(), [&](auto& d) { return std::ranges::any_of(*detections, [&](const auto& d) {
// This is a spurious digital detection if a "smooth" (analog) detection is temporally near. // This is a spurious digital detection if a "smooth" (analog) detection is temporally near.
return &d != &detection && d.smoothness > 1 && d.smoothness > detection.smoothness && return &d != &detection && d.smoothness > 1 && d.smoothness > detection.smoothness &&
abs(d.press_time - detection.press_time) < SPURIOUS_TRIGGER_COMBO_THRESHOLD; abs(d.press_time - detection.press_time) < SPURIOUS_TRIGGER_COMBO_THRESHOLD;

View File

@ -304,8 +304,8 @@ void OGLGfx::DispatchComputeShader(const AbstractShader* shader, u32 groupsize_x
static_cast<const OGLPipeline*>(m_current_pipeline)->GetProgram()->shader.Bind(); static_cast<const OGLPipeline*>(m_current_pipeline)->GetProgram()->shader.Bind();
// Barrier to texture can be used for reads. // Barrier to texture can be used for reads.
if (std::any_of(m_bound_image_textures.begin(), m_bound_image_textures.end(), if (std::ranges::any_of(m_bound_image_textures,
[](auto image) { return image != nullptr; })) [](const auto* image) { return image != nullptr; }))
{ {
glMemoryBarrier(GL_TEXTURE_UPDATE_BARRIER_BIT); glMemoryBarrier(GL_TEXTURE_UPDATE_BARRIER_BIT);
} }

View File

@ -929,8 +929,8 @@ void VulkanContext::DisableDebugUtils()
bool VulkanContext::SupportsDeviceExtension(const char* name) const bool VulkanContext::SupportsDeviceExtension(const char* name) const
{ {
return std::any_of(m_device_extensions.begin(), m_device_extensions.end(), return std::ranges::any_of(m_device_extensions,
[name](const std::string& extension) { return extension == name; }); [name](const std::string& extension) { return extension == name; });
} }
static bool DriverIsMesa(VkDriverId driver_id) static bool DriverIsMesa(VkDriverId driver_id)

View File

@ -69,10 +69,8 @@ CustomAssetLibrary::LoadInfo CustomAssetLibrary::LoadGameTexture(const AssetID&
} }
// All levels have to have the same format. // All levels have to have the same format.
if (std::any_of(slice.m_levels.begin(), slice.m_levels.end(), if (std::ranges::any_of(slice.m_levels,
[&first_mip](const VideoCommon::CustomTextureData::ArraySlice::Level& l) { [&first_mip](const auto& l) { return l.format != first_mip.format; }))
return l.format != first_mip.format;
}))
{ {
ERROR_LOG_FMT( ERROR_LOG_FMT(
VIDEO, "Custom game texture {} has inconsistent formats across mip levels for slice {}.", VIDEO, "Custom game texture {} has inconsistent formats across mip levels for slice {}.",