mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-24 22:34:54 +00:00
Merge pull request #13117 from mitaclaw/ranges-modernization-9-trivial-find
Ranges Algorithms Modernization - Find
This commit is contained in:
commit
c1832d17f6
32 changed files with 71 additions and 84 deletions
|
@ -85,7 +85,7 @@ bool IniFile::Section::Delete(std::string_view key)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
values.erase(it);
|
values.erase(it);
|
||||||
keys_order.erase(std::find(keys_order.begin(), keys_order.end(), key));
|
keys_order.erase(std::ranges::find(keys_order, key));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ static std::optional<DiscIO::Language> TryParseLanguage(const std::string& local
|
||||||
"ja", "en", "de", "fr", "es", "it", "nl", "zh", "zh", "ko",
|
"ja", "en", "de", "fr", "es", "it", "nl", "zh", "zh", "ko",
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto it = std::find(LANGUAGES.cbegin(), LANGUAGES.cend(), split_locale[0]);
|
const auto it = std::ranges::find(LANGUAGES, split_locale[0]);
|
||||||
if (it == LANGUAGES.cend())
|
if (it == LANGUAGES.cend())
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ static std::optional<u8> ComputeDefaultCountry()
|
||||||
if (country == "BQ" || country == "CW" || country == "SX")
|
if (country == "BQ" || country == "CW" || country == "SX")
|
||||||
country = "AN";
|
country = "AN";
|
||||||
|
|
||||||
const auto it = std::find(COUNTRIES.cbegin(), COUNTRIES.cend(), country);
|
const auto it = std::ranges::find(COUNTRIES, country);
|
||||||
if (it == COUNTRIES.cend())
|
if (it == COUNTRIES.cend())
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
|
|
|
@ -153,10 +153,9 @@ static std::pair<std::string, std::string> GetINILocationFromConfig(const Locati
|
||||||
return it->first;
|
return it->first;
|
||||||
|
|
||||||
static const INIToSectionMap& ini_to_section = GetINIToSectionMap();
|
static const INIToSectionMap& ini_to_section = GetINIToSectionMap();
|
||||||
const auto it2 =
|
const auto it2 = std::ranges::find_if(ini_to_section, [&location](const auto& entry) {
|
||||||
std::find_if(ini_to_section.begin(), ini_to_section.end(), [&location](const auto& entry) {
|
return entry.second.first == location.system && entry.second.second == location.section;
|
||||||
return entry.second.first == location.system && entry.second.second == location.section;
|
});
|
||||||
});
|
|
||||||
if (it2 != ini_to_section.end())
|
if (it2 != ini_to_section.end())
|
||||||
return {it2->first, location.key};
|
return {it2->first, location.key};
|
||||||
|
|
||||||
|
|
|
@ -113,8 +113,7 @@ const DSPOPCTemplate* GetExtOpTemplate(UDSPInstruction inst);
|
||||||
template <typename T, size_t N>
|
template <typename T, size_t N>
|
||||||
auto FindByOpcode(UDSPInstruction opcode, const std::array<T, N>& data)
|
auto FindByOpcode(UDSPInstruction opcode, const std::array<T, N>& data)
|
||||||
{
|
{
|
||||||
return std::find_if(data.cbegin(), data.cend(), [opcode](const auto& info) {
|
return std::ranges::find_if(
|
||||||
return (opcode & info.opcode_mask) == info.opcode;
|
data, [opcode](const auto& info) { return (opcode & info.opcode_mask) == info.opcode; });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} // namespace DSP
|
} // namespace DSP
|
||||||
|
|
|
@ -252,7 +252,7 @@ HitType CodeTrace::TraceLogic(const TraceOutput& current_instr, bool first_hit)
|
||||||
return HitType::SKIP;
|
return HitType::SKIP;
|
||||||
|
|
||||||
// The reg_itr will be used later for erasing.
|
// The reg_itr will be used later for erasing.
|
||||||
auto reg_itr = std::find(m_reg_autotrack.begin(), m_reg_autotrack.end(), instr.reg0);
|
auto reg_itr = std::ranges::find(m_reg_autotrack, instr.reg0);
|
||||||
const bool match_reg123 =
|
const bool match_reg123 =
|
||||||
(!instr.reg1.empty() && std::find(m_reg_autotrack.begin(), m_reg_autotrack.end(),
|
(!instr.reg1.empty() && std::find(m_reg_autotrack.begin(), m_reg_autotrack.end(),
|
||||||
instr.reg1) != m_reg_autotrack.end()) ||
|
instr.reg1) != m_reg_autotrack.end()) ||
|
||||||
|
|
|
@ -331,18 +331,16 @@ private:
|
||||||
std::vector<AccessorMapping>::iterator FindAppropriateAccessor(const Core::CPUThreadGuard& guard,
|
std::vector<AccessorMapping>::iterator FindAppropriateAccessor(const Core::CPUThreadGuard& guard,
|
||||||
u32 address)
|
u32 address)
|
||||||
{
|
{
|
||||||
return std::find_if(m_accessor_mappings.begin(), m_accessor_mappings.end(),
|
return std::ranges::find_if(m_accessor_mappings, [&guard, address](const AccessorMapping& a) {
|
||||||
[&guard, address](const AccessorMapping& a) {
|
return a.accessors->IsValidAddress(guard, address - a.base);
|
||||||
return a.accessors->IsValidAddress(guard, address - a.base);
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
std::vector<AccessorMapping>::const_iterator
|
std::vector<AccessorMapping>::const_iterator
|
||||||
FindAppropriateAccessor(const Core::CPUThreadGuard& guard, u32 address) const
|
FindAppropriateAccessor(const Core::CPUThreadGuard& guard, u32 address) const
|
||||||
{
|
{
|
||||||
return std::find_if(m_accessor_mappings.begin(), m_accessor_mappings.end(),
|
return std::ranges::find_if(m_accessor_mappings, [&guard, address](const AccessorMapping& a) {
|
||||||
[&guard, address](const AccessorMapping& a) {
|
return a.accessors->IsValidAddress(guard, address - a.base);
|
||||||
return a.accessors->IsValidAddress(guard, address - a.base);
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -146,8 +146,8 @@ std::vector<std::string> GCMemcardDirectory::GetFileNamesForGameID(const std::st
|
||||||
if (!gci_file.ReadBytes(&gci.m_gci_header, Memcard::DENTRY_SIZE))
|
if (!gci_file.ReadBytes(&gci.m_gci_header, Memcard::DENTRY_SIZE))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const auto same_identity_save_it = std::find_if(
|
const auto same_identity_save_it =
|
||||||
loaded_saves.begin(), loaded_saves.end(), [&gci](const Memcard::DEntry& entry) {
|
std::ranges::find_if(loaded_saves, [&gci](const Memcard::DEntry& entry) {
|
||||||
return Memcard::HasSameIdentity(gci.m_gci_header, entry);
|
return Memcard::HasSameIdentity(gci.m_gci_header, entry);
|
||||||
});
|
});
|
||||||
if (same_identity_save_it != loaded_saves.end())
|
if (same_identity_save_it != loaded_saves.end())
|
||||||
|
|
|
@ -420,8 +420,8 @@ ControllerEmu::ControlGroup* HotkeyManager::GetHotkeyGroup(HotkeyGroup group) co
|
||||||
|
|
||||||
int HotkeyManager::FindGroupByID(int id) const
|
int HotkeyManager::FindGroupByID(int id) const
|
||||||
{
|
{
|
||||||
const auto i = std::find_if(s_groups_info.begin(), s_groups_info.end(),
|
const auto i =
|
||||||
[id](const auto& entry) { return entry.last >= id; });
|
std::ranges::find_if(s_groups_info, [id](const auto& entry) { return entry.last >= id; });
|
||||||
|
|
||||||
return static_cast<int>(std::distance(s_groups_info.begin(), i));
|
return static_cast<int>(std::distance(s_groups_info.begin(), i));
|
||||||
}
|
}
|
||||||
|
|
|
@ -527,14 +527,13 @@ void ESDevice::DoState(PointerWrap& p)
|
||||||
|
|
||||||
ESDevice::ContextArray::iterator ESDevice::FindActiveContext(s32 fd)
|
ESDevice::ContextArray::iterator ESDevice::FindActiveContext(s32 fd)
|
||||||
{
|
{
|
||||||
return std::find_if(m_contexts.begin(), m_contexts.end(),
|
return std::ranges::find_if(
|
||||||
[fd](const auto& context) { return context.ipc_fd == fd && context.active; });
|
m_contexts, [fd](const auto& context) { return context.ipc_fd == fd && context.active; });
|
||||||
}
|
}
|
||||||
|
|
||||||
ESDevice::ContextArray::iterator ESDevice::FindInactiveContext()
|
ESDevice::ContextArray::iterator ESDevice::FindInactiveContext()
|
||||||
{
|
{
|
||||||
return std::find_if(m_contexts.begin(), m_contexts.end(),
|
return std::ranges::find_if(m_contexts, [](const auto& context) { return !context.active; });
|
||||||
[](const auto& context) { return !context.active; });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<IPCReply> ESDevice::Open(const OpenRequest& request)
|
std::optional<IPCReply> ESDevice::Open(const OpenRequest& request)
|
||||||
|
|
|
@ -721,7 +721,7 @@ CertReader::CertReader(std::vector<u8>&& bytes) : SignedBlobReader(std::move(byt
|
||||||
{SignatureType::ECC, PublicKeyType::ECC, sizeof(CertECC)},
|
{SignatureType::ECC, PublicKeyType::ECC, sizeof(CertECC)},
|
||||||
}};
|
}};
|
||||||
|
|
||||||
const auto info = std::find_if(types.cbegin(), types.cend(), [this](const CertStructInfo& entry) {
|
const auto info = std::ranges::find_if(types, [this](const CertStructInfo& entry) {
|
||||||
return m_bytes.size() >= std::get<2>(entry) && std::get<0>(entry) == GetSignatureType() &&
|
return m_bytes.size() >= std::get<2>(entry) && std::get<0>(entry) == GetSignatureType() &&
|
||||||
std::get<1>(entry) == GetPublicKeyType();
|
std::get<1>(entry) == GetPublicKeyType();
|
||||||
});
|
});
|
||||||
|
|
|
@ -139,7 +139,7 @@ ReturnCode ESCore::VerifySign(const std::vector<u8>& hash, const std::vector<u8>
|
||||||
if (certs.empty())
|
if (certs.empty())
|
||||||
return ES_EINVAL;
|
return ES_EINVAL;
|
||||||
|
|
||||||
const auto ap_iterator = std::find_if(certs.begin(), certs.end(), [](const auto& entry) {
|
const auto ap_iterator = std::ranges::find_if(certs, [](const auto& entry) {
|
||||||
return entry.first.length() > 2 && entry.first.compare(0, 2, "AP") == 0;
|
return entry.first.length() > 2 && entry.first.compare(0, 2, "AP") == 0;
|
||||||
});
|
});
|
||||||
if (ap_iterator == certs.end())
|
if (ap_iterator == certs.end())
|
||||||
|
|
|
@ -207,8 +207,8 @@ Result<FileStatus> HostFileSystem::GetFileStatus(Fd fd)
|
||||||
|
|
||||||
HostFileSystem::Handle* HostFileSystem::AssignFreeHandle()
|
HostFileSystem::Handle* HostFileSystem::AssignFreeHandle()
|
||||||
{
|
{
|
||||||
const auto it = std::find_if(m_handles.begin(), m_handles.end(),
|
const auto it =
|
||||||
[](const Handle& handle) { return !handle.opened; });
|
std::ranges::find_if(m_handles, [](const Handle& handle) { return !handle.opened; });
|
||||||
if (it == m_handles.end())
|
if (it == m_handles.end())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|
|
@ -669,8 +669,7 @@ IOSC::KeyEntry::KeyEntry(ObjectType type_, ObjectSubType subtype_, std::vector<u
|
||||||
|
|
||||||
IOSC::KeyEntries::iterator IOSC::FindFreeEntry()
|
IOSC::KeyEntries::iterator IOSC::FindFreeEntry()
|
||||||
{
|
{
|
||||||
return std::find_if(m_key_entries.begin(), m_key_entries.end(),
|
return std::ranges::find_if(m_key_entries, [](const auto& entry) { return !entry.in_use; });
|
||||||
[](const auto& entry) { return !entry.in_use; });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IOSC::KeyEntry* IOSC::FindEntry(Handle handle)
|
IOSC::KeyEntry* IOSC::FindEntry(Handle handle)
|
||||||
|
|
|
@ -473,8 +473,7 @@ bool BluetoothEmuDevice::SendEventInquiryResponse()
|
||||||
static_assert(
|
static_assert(
|
||||||
sizeof(SHCIEventInquiryResult) - 2 + (num_responses * sizeof(hci_inquiry_response)) < 256);
|
sizeof(SHCIEventInquiryResult) - 2 + (num_responses * sizeof(hci_inquiry_response)) < 256);
|
||||||
|
|
||||||
const auto iter = std::find_if(m_wiimotes.begin(), m_wiimotes.end(),
|
const auto iter = std::ranges::find_if(m_wiimotes, &WiimoteDevice::IsInquiryScanEnabled);
|
||||||
std::mem_fn(&WiimoteDevice::IsInquiryScanEnabled));
|
|
||||||
if (iter == m_wiimotes.end())
|
if (iter == m_wiimotes.end())
|
||||||
{
|
{
|
||||||
// No remotes are discoverable.
|
// No remotes are discoverable.
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <ranges>
|
||||||
|
|
||||||
#include "Common/Assert.h"
|
#include "Common/Assert.h"
|
||||||
#include "Common/ChunkFile.h"
|
#include "Common/ChunkFile.h"
|
||||||
|
@ -215,8 +216,8 @@ void USBV5ResourceManager::OnDeviceChange(const ChangeEvent event,
|
||||||
if (interface.bAlternateSetting != 0)
|
if (interface.bAlternateSetting != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto it = std::find_if(m_usbv5_devices.rbegin(), m_usbv5_devices.rend(),
|
auto it = std::ranges::find_if(m_usbv5_devices | std::views::reverse,
|
||||||
[](const USBV5Device& entry) { return !entry.in_use; });
|
[](const USBV5Device& entry) { return !entry.in_use; });
|
||||||
if (it == m_usbv5_devices.rend())
|
if (it == m_usbv5_devices.rend())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -169,11 +169,10 @@ IPCReply USB_HIDv5::GetDeviceInfo(USBV5Device& device, const IOCtlRequest& reque
|
||||||
memory.CopyToEmu(request.buffer_out + 56, &config_descriptor, sizeof(config_descriptor));
|
memory.CopyToEmu(request.buffer_out + 56, &config_descriptor, sizeof(config_descriptor));
|
||||||
|
|
||||||
std::vector<USB::InterfaceDescriptor> interfaces = host_device->GetInterfaces(0);
|
std::vector<USB::InterfaceDescriptor> interfaces = host_device->GetInterfaces(0);
|
||||||
auto it = std::find_if(interfaces.begin(), interfaces.end(),
|
auto it = std::ranges::find_if(interfaces, [&](const USB::InterfaceDescriptor& interface) {
|
||||||
[&](const USB::InterfaceDescriptor& interface) {
|
return interface.bInterfaceNumber == device.interface_number &&
|
||||||
return interface.bInterfaceNumber == device.interface_number &&
|
interface.bAlternateSetting == alt_setting;
|
||||||
interface.bAlternateSetting == alt_setting;
|
});
|
||||||
});
|
|
||||||
if (it == interfaces.end())
|
if (it == interfaces.end())
|
||||||
return IPCReply(IPC_EINVAL);
|
return IPCReply(IPC_EINVAL);
|
||||||
it->Swap();
|
it->Swap();
|
||||||
|
|
|
@ -152,11 +152,10 @@ IPCReply USB_VEN::GetDeviceInfo(USBV5Device& device, const IOCtlRequest& request
|
||||||
memory.CopyToEmu(request.buffer_out + 40, &config_descriptor, sizeof(config_descriptor));
|
memory.CopyToEmu(request.buffer_out + 40, &config_descriptor, sizeof(config_descriptor));
|
||||||
|
|
||||||
std::vector<USB::InterfaceDescriptor> interfaces = host_device->GetInterfaces(0);
|
std::vector<USB::InterfaceDescriptor> interfaces = host_device->GetInterfaces(0);
|
||||||
auto it = std::find_if(interfaces.begin(), interfaces.end(),
|
auto it = std::ranges::find_if(interfaces, [&](const USB::InterfaceDescriptor& interface) {
|
||||||
[&](const USB::InterfaceDescriptor& interface) {
|
return interface.bInterfaceNumber == device.interface_number &&
|
||||||
return interface.bInterfaceNumber == device.interface_number &&
|
interface.bAlternateSetting == alt_setting;
|
||||||
interface.bAlternateSetting == alt_setting;
|
});
|
||||||
});
|
|
||||||
if (it == interfaces.end())
|
if (it == interfaces.end())
|
||||||
return IPCReply(IPC_EINVAL);
|
return IPCReply(IPC_EINVAL);
|
||||||
it->Swap();
|
it->Swap();
|
||||||
|
|
|
@ -77,7 +77,7 @@ std::optional<PatchEntry> DeserializeLine(std::string line)
|
||||||
entry.conditional = true;
|
entry.conditional = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto iter = std::find(s_patch_type_strings.begin(), s_patch_type_strings.end(), items[1]);
|
const auto iter = std::ranges::find(s_patch_type_strings, items[1]);
|
||||||
if (iter == s_patch_type_strings.end())
|
if (iter == s_patch_type_strings.end())
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
entry.type = static_cast<PatchType>(std::distance(s_patch_type_strings.begin(), iter));
|
entry.type = static_cast<PatchType>(std::distance(s_patch_type_strings.begin(), iter));
|
||||||
|
|
|
@ -352,10 +352,9 @@ void MemChecks::Clear()
|
||||||
|
|
||||||
TMemCheck* MemChecks::GetMemCheck(u32 address, size_t size)
|
TMemCheck* MemChecks::GetMemCheck(u32 address, size_t size)
|
||||||
{
|
{
|
||||||
const auto iter =
|
const auto iter = std::ranges::find_if(m_mem_checks, [address, size](const auto& mc) {
|
||||||
std::find_if(m_mem_checks.begin(), m_mem_checks.end(), [address, size](const auto& mc) {
|
return mc.end_address >= address && address + size - 1 >= mc.start_address;
|
||||||
return mc.end_address >= address && address + size - 1 >= mc.start_address;
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// None found
|
// None found
|
||||||
if (iter == m_mem_checks.cend())
|
if (iter == m_mem_checks.cend())
|
||||||
|
|
|
@ -117,10 +117,9 @@ void Reload()
|
||||||
|
|
||||||
std::optional<std::string> GetNetworkPatch(std::string_view source, IsKD is_kd)
|
std::optional<std::string> GetNetworkPatch(std::string_view source, IsKD is_kd)
|
||||||
{
|
{
|
||||||
const auto patch =
|
const auto patch = std::ranges::find_if(s_patches, [&source, &is_kd](const NetworkPatch& p) {
|
||||||
std::find_if(s_patches.begin(), s_patches.end(), [&source, &is_kd](const NetworkPatch& p) {
|
return p.source == source && p.is_kd == is_kd && p.enabled;
|
||||||
return p.source == source && p.is_kd == is_kd && p.enabled;
|
});
|
||||||
});
|
|
||||||
if (patch == s_patches.end())
|
if (patch == s_patches.end())
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,8 @@ SectorReader::~SectorReader()
|
||||||
|
|
||||||
const SectorReader::Cache* SectorReader::FindCacheLine(u64 block_num)
|
const SectorReader::Cache* SectorReader::FindCacheLine(u64 block_num)
|
||||||
{
|
{
|
||||||
auto itr = std::find_if(m_cache.begin(), m_cache.end(),
|
auto itr =
|
||||||
[&](const Cache& entry) { return entry.Contains(block_num); });
|
std::ranges::find_if(m_cache, [&](const Cache& entry) { return entry.Contains(block_num); });
|
||||||
if (itr == m_cache.end())
|
if (itr == m_cache.end())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
|
|
@ -366,7 +366,7 @@ static FSTBuilderNode* FindFileNodeInFST(std::string_view path, std::vector<FSTB
|
||||||
const size_t path_separator = path.find('/');
|
const size_t path_separator = path.find('/');
|
||||||
const bool is_file = path_separator == std::string_view::npos;
|
const bool is_file = path_separator == std::string_view::npos;
|
||||||
const std::string_view name = is_file ? path : path.substr(0, path_separator);
|
const std::string_view name = is_file ? path : path.substr(0, path_separator);
|
||||||
const auto it = std::find_if(fst->begin(), fst->end(), [&](const FSTBuilderNode& node) {
|
const auto it = std::ranges::find_if(*fst, [&](const FSTBuilderNode& node) {
|
||||||
return Common::CaseInsensitiveEquals(node.m_filename, name);
|
return Common::CaseInsensitiveEquals(node.m_filename, name);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -472,8 +472,7 @@ std::vector<Partition> VolumeVerifier::CheckPartitions()
|
||||||
AddProblem(Severity::High, Common::GetStringT("The install partition is missing."));
|
AddProblem(Severity::High, Common::GetStringT("The install partition is missing."));
|
||||||
|
|
||||||
if (ShouldHaveMasterpiecePartitions() &&
|
if (ShouldHaveMasterpiecePartitions() &&
|
||||||
types.cend() ==
|
types.cend() == std::ranges::find_if(types, [](u32 type) { return type >= 0xFF; }))
|
||||||
std::find_if(types.cbegin(), types.cend(), [](u32 type) { return type >= 0xFF; }))
|
|
||||||
{
|
{
|
||||||
// i18n: This string is referring to a game mode in Super Smash Bros. Brawl called Masterpieces
|
// i18n: This string is referring to a game mode in Super Smash Bros. Brawl called Masterpieces
|
||||||
// where you play demos of NES/SNES/N64 games. Official translations:
|
// where you play demos of NES/SNES/N64 games. Official translations:
|
||||||
|
|
|
@ -396,7 +396,7 @@ void GeckoCodeWidget::DownloadCodes()
|
||||||
|
|
||||||
for (const auto& code : codes)
|
for (const auto& code : codes)
|
||||||
{
|
{
|
||||||
auto it = std::find(m_gecko_codes.begin(), m_gecko_codes.end(), code);
|
auto it = std::ranges::find(m_gecko_codes, code);
|
||||||
|
|
||||||
if (it == m_gecko_codes.end())
|
if (it == m_gecko_codes.end())
|
||||||
{
|
{
|
||||||
|
|
|
@ -162,10 +162,9 @@ void GekkoSyntaxHighlight::highlightBlock(const QString& text)
|
||||||
}
|
}
|
||||||
else if (m_mode == 1)
|
else if (m_mode == 1)
|
||||||
{
|
{
|
||||||
auto paren_it = std::find_if(info->parens.begin(), info->parens.end(),
|
auto paren_it = std::ranges::find_if(info->parens, [this](const std::pair<int, int>& p) {
|
||||||
[this](const std::pair<int, int>& p) {
|
return p.first == m_cursor_loc || p.second == m_cursor_loc;
|
||||||
return p.first == m_cursor_loc || p.second == m_cursor_loc;
|
});
|
||||||
});
|
|
||||||
if (paren_it != info->parens.end())
|
if (paren_it != info->parens.end())
|
||||||
{
|
{
|
||||||
HighlightSubstr(paren_it->first, 1, HighlightFormat::Paren);
|
HighlightSubstr(paren_it->first, 1, HighlightFormat::Paren);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <bit>
|
#include <bit>
|
||||||
|
#include <ranges>
|
||||||
|
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
@ -472,9 +473,8 @@ void FIFOAnalyzer::FindNext()
|
||||||
const int index = m_detail_list->currentRow();
|
const int index = m_detail_list->currentRow();
|
||||||
ASSERT(index >= 0);
|
ASSERT(index >= 0);
|
||||||
|
|
||||||
auto next_result =
|
auto next_result = std::ranges::find_if(
|
||||||
std::find_if(m_search_results.begin(), m_search_results.end(),
|
m_search_results, [index](auto& result) { return result.m_cmd > static_cast<u32>(index); });
|
||||||
[index](auto& result) { return result.m_cmd > static_cast<u32>(index); });
|
|
||||||
if (next_result != m_search_results.end())
|
if (next_result != m_search_results.end())
|
||||||
{
|
{
|
||||||
ShowSearchResult(next_result - m_search_results.begin());
|
ShowSearchResult(next_result - m_search_results.begin());
|
||||||
|
@ -487,8 +487,9 @@ void FIFOAnalyzer::FindPrevious()
|
||||||
ASSERT(index >= 0);
|
ASSERT(index >= 0);
|
||||||
|
|
||||||
auto prev_result =
|
auto prev_result =
|
||||||
std::find_if(m_search_results.rbegin(), m_search_results.rend(),
|
std::ranges::find_if(m_search_results | std::views::reverse, [index](auto& result) {
|
||||||
[index](auto& result) { return result.m_cmd < static_cast<u32>(index); });
|
return result.m_cmd < static_cast<u32>(index);
|
||||||
|
});
|
||||||
if (prev_result != m_search_results.rend())
|
if (prev_result != m_search_results.rend())
|
||||||
{
|
{
|
||||||
ShowSearchResult((m_search_results.rend() - prev_result) - 1);
|
ShowSearchResult((m_search_results.rend() - prev_result) - 1);
|
||||||
|
|
|
@ -145,8 +145,7 @@ void GameDigestDialog::SetResult(int pid, const std::string& result)
|
||||||
auto client = Settings::Instance().GetNetPlayClient();
|
auto client = Settings::Instance().GetNetPlayClient();
|
||||||
if (client && m_results.size() >= client->GetPlayers().size())
|
if (client && m_results.size() >= client->GetPlayers().size())
|
||||||
{
|
{
|
||||||
if (std::adjacent_find(m_results.begin(), m_results.end(), std::not_equal_to<>()) ==
|
if (std::ranges::adjacent_find(m_results, std::ranges::not_equal_to{}) == m_results.end())
|
||||||
m_results.end())
|
|
||||||
{
|
{
|
||||||
m_check_label->setText(tr("The hashes match!"));
|
m_check_label->setText(tr("The hashes match!"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ std::vector<ResourcePack>& GetPacks()
|
||||||
std::vector<ResourcePack*> GetLowerPriorityPacks(const ResourcePack& pack)
|
std::vector<ResourcePack*> GetLowerPriorityPacks(const ResourcePack& pack)
|
||||||
{
|
{
|
||||||
std::vector<ResourcePack*> list;
|
std::vector<ResourcePack*> list;
|
||||||
for (auto it = std::find(packs.begin(), packs.end(), pack) + 1; it != packs.end(); ++it)
|
for (auto it = std::ranges::find(packs, pack) + 1; it != packs.end(); ++it)
|
||||||
{
|
{
|
||||||
auto& entry = *it;
|
auto& entry = *it;
|
||||||
if (!IsInstalled(pack))
|
if (!IsInstalled(pack))
|
||||||
|
@ -100,7 +100,7 @@ std::vector<ResourcePack*> GetLowerPriorityPacks(const ResourcePack& pack)
|
||||||
std::vector<ResourcePack*> GetHigherPriorityPacks(const ResourcePack& pack)
|
std::vector<ResourcePack*> GetHigherPriorityPacks(const ResourcePack& pack)
|
||||||
{
|
{
|
||||||
std::vector<ResourcePack*> list;
|
std::vector<ResourcePack*> list;
|
||||||
auto end = std::find(packs.begin(), packs.end(), pack);
|
auto end = std::ranges::find(packs, pack);
|
||||||
|
|
||||||
for (auto it = packs.begin(); it != end; ++it)
|
for (auto it = packs.begin(); it != end; ++it)
|
||||||
{
|
{
|
||||||
|
@ -145,7 +145,7 @@ bool Remove(ResourcePack& pack)
|
||||||
if (!result)
|
if (!result)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto pack_iterator = std::find(packs.begin(), packs.end(), pack);
|
auto pack_iterator = std::ranges::find(packs, pack);
|
||||||
|
|
||||||
if (pack_iterator == packs.end())
|
if (pack_iterator == packs.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -170,10 +170,9 @@ bool ResourcePack::Install(const std::string& path)
|
||||||
continue;
|
continue;
|
||||||
const std::string texture_name = texture_zip_path.substr(texture_zip_path_prefix.size());
|
const std::string texture_name = texture_zip_path.substr(texture_zip_path_prefix.size());
|
||||||
|
|
||||||
auto texture_it = std::find_if(
|
auto texture_it = std::ranges::find_if(m_textures, [&texture_name](const std::string& texture) {
|
||||||
m_textures.cbegin(), m_textures.cend(), [&texture_name](const std::string& texture) {
|
return mz_path_compare_wc(texture.c_str(), texture_name.c_str(), 1) == MZ_OK;
|
||||||
return mz_path_compare_wc(texture.c_str(), texture_name.c_str(), 1) == MZ_OK;
|
});
|
||||||
});
|
|
||||||
if (texture_it == m_textures.cend())
|
if (texture_it == m_textures.cend())
|
||||||
continue;
|
continue;
|
||||||
const auto texture = *texture_it;
|
const auto texture = *texture_it;
|
||||||
|
|
|
@ -61,8 +61,8 @@ static NSString* GetName(Metal::StateTracker::UploadBuffer buffer)
|
||||||
|
|
||||||
bool Metal::StateTracker::UsageTracker::PrepareForAllocation(u64 last_draw, size_t amt)
|
bool Metal::StateTracker::UsageTracker::PrepareForAllocation(u64 last_draw, size_t amt)
|
||||||
{
|
{
|
||||||
auto removeme = std::find_if(m_usage.begin(), m_usage.end(),
|
auto removeme = std::ranges::find_if(
|
||||||
[last_draw](UsageEntry usage) { return usage.drawno > last_draw; });
|
m_usage, [last_draw](UsageEntry usage) { return usage.drawno > last_draw; });
|
||||||
if (removeme != m_usage.begin())
|
if (removeme != m_usage.begin())
|
||||||
m_usage.erase(m_usage.begin(), removeme);
|
m_usage.erase(m_usage.begin(), removeme);
|
||||||
|
|
||||||
|
|
|
@ -176,7 +176,7 @@ void Statistics::AddScissorRect()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
add = std::find_if(scissors.begin(), scissors.end(), [&](auto& s) {
|
add = std::ranges::find_if(scissors, [&](auto& s) {
|
||||||
return s.Matches(scissor, show_scissors, show_viewports);
|
return s.Matches(scissor, show_scissors, show_viewports);
|
||||||
}) == scissors.end();
|
}) == scissors.end();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2814,7 +2814,7 @@ TextureCacheBase::InvalidateTexture(TexAddrCache::iterator iter, bool discard_pe
|
||||||
// Xenoblade's sunset scene, where 35 copies are done per frame, and 25 of them are
|
// Xenoblade's sunset scene, where 35 copies are done per frame, and 25 of them are
|
||||||
// copied to the same address, and can be skipped.
|
// copied to the same address, and can be skipped.
|
||||||
ReleaseEFBCopyStagingTexture(std::move(entry->pending_efb_copy));
|
ReleaseEFBCopyStagingTexture(std::move(entry->pending_efb_copy));
|
||||||
auto pending_it = std::find(m_pending_efb_copies.begin(), m_pending_efb_copies.end(), entry);
|
auto pending_it = std::ranges::find(m_pending_efb_copies, entry);
|
||||||
if (pending_it != m_pending_efb_copies.end())
|
if (pending_it != m_pending_efb_copies.end())
|
||||||
m_pending_efb_copies.erase(pending_it);
|
m_pending_efb_copies.erase(pending_it);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue