diff options
| author | Tilka <tilkax@gmail.com> | 2024-07-21 19:06:55 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-21 19:06:55 +0100 |
| commit | 7bd2a7bde301c9dc255ae45e60fcfcd8ba10aecc (patch) | |
| tree | 3494efb586ed037db2c63b13d7f482f4599bfedc /Source/Core | |
| parent | 652245006dc947c63b118174d216b24779aa1f21 (diff) | |
| parent | 982893b04cb3605f7703ebf2b9a99d33efa3b3eb (diff) | |
Merge pull request #12945 from Tilka/erase_if
Use C++20 erase_if() instead of erase(remove_if()) (NFC)
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/CoreTiming.cpp | 7 | ||||
| -rw-r--r-- | Source/Core/DiscIO/DiscUtils.cpp | 8 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/GameList/GameList.cpp | 14 | ||||
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp | 6 |
4 files changed, 13 insertions, 22 deletions
diff --git a/Source/Core/Core/CoreTiming.cpp b/Source/Core/Core/CoreTiming.cpp index b304ff2fa6..7fe8160da8 100644 --- a/Source/Core/Core/CoreTiming.cpp +++ b/Source/Core/Core/CoreTiming.cpp @@ -282,13 +282,12 @@ void CoreTimingManager::ScheduleEvent(s64 cycles_into_future, EventType* event_t void CoreTimingManager::RemoveEvent(EventType* event_type) { - auto itr = std::remove_if(m_event_queue.begin(), m_event_queue.end(), - [&](const Event& e) { return e.type == event_type; }); + const size_t erased = + std::erase_if(m_event_queue, [&](const Event& e) { return e.type == event_type; }); // Removing random items breaks the invariant so we have to re-establish it. - if (itr != m_event_queue.end()) + if (erased != 0) { - m_event_queue.erase(itr, m_event_queue.end()); std::make_heap(m_event_queue.begin(), m_event_queue.end(), std::greater<Event>()); } } diff --git a/Source/Core/DiscIO/DiscUtils.cpp b/Source/Core/DiscIO/DiscUtils.cpp index cdfcb015c4..afd22117c6 100644 --- a/Source/Core/DiscIO/DiscUtils.cpp +++ b/Source/Core/DiscIO/DiscUtils.cpp @@ -131,11 +131,9 @@ u64 GetBiggestReferencedOffset(const Volume& volume) // This can happen when certain programs that create WBFS files scrub the entirety of // the Masterpiece partitions in Super Smash Bros. Brawl without removing them from // the partition table. https://bugs.dolphin-emu.org/issues/8733 - const auto it = - std::remove_if(partitions.begin(), partitions.end(), [&](const Partition& partition) { - return volume.ReadSwapped<u32>(0x18, partition) != WII_DISC_MAGIC; - }); - partitions.erase(it, partitions.end()); + std::erase_if(partitions, [&](const Partition& partition) { + return volume.ReadSwapped<u32>(0x18, partition) != WII_DISC_MAGIC; + }); if (partitions.empty()) partitions.push_back(PARTITION_NONE); diff --git a/Source/Core/DolphinQt/GameList/GameList.cpp b/Source/Core/DolphinQt/GameList/GameList.cpp index 97c596b969..f1d69613a3 100644 --- a/Source/Core/DolphinQt/GameList/GameList.cpp +++ b/Source/Core/DolphinQt/GameList/GameList.cpp @@ -803,15 +803,11 @@ bool GameList::AddShortcutToDesktop() std::string game_name = game->GetName(Core::TitleDatabase()); // Sanitize the string by removing all characters that cannot be used in NTFS file names - game_name.erase(std::remove_if(game_name.begin(), game_name.end(), - [](char ch) { - static constexpr char illegal_characters[] = { - '<', '>', ':', '\"', '/', '\\', '|', '?', '*'}; - return std::find(std::begin(illegal_characters), - std::end(illegal_characters), - ch) != std::end(illegal_characters); - }), - game_name.end()); + std::erase_if(game_name, [](char ch) { + static constexpr char illegal_characters[] = {'<', '>', ':', '\"', '/', '\\', '|', '?', '*'}; + return std::find(std::begin(illegal_characters), std::end(illegal_characters), ch) != + std::end(illegal_characters); + }); std::wstring desktop_path = std::wstring(desktop.get()) + UTF8ToTStr("\\" + game_name + ".lnk"); auto persist_file = shell_link.try_query<IPersistFile>(); diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index ab266292bc..769e6c5f0e 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -308,7 +308,7 @@ void ControllerInterface::RemoveDevice(std::function<bool(const ciface::Core::De bool any_removed; { std::lock_guard lk(m_devices_mutex); - auto it = std::remove_if(m_devices.begin(), m_devices.end(), [&callback](const auto& dev) { + const size_t erased = std::erase_if(m_devices, [&callback](const auto& dev) { if (callback(dev.get())) { NOTICE_LOG_FMT(CONTROLLERINTERFACE, "Removed device: {}", dev->GetQualifiedName()); @@ -316,9 +316,7 @@ void ControllerInterface::RemoveDevice(std::function<bool(const ciface::Core::De } return false; }); - const size_t prev_size = m_devices.size(); - m_devices.erase(it, m_devices.end()); - any_removed = m_devices.size() != prev_size; + any_removed = erased != 0; } if (any_removed && (!m_populating_devices_counter || force_devices_release)) |
