Merge pull request #12945 from Tilka/erase_if
Use C++20 erase_if() instead of erase(remove_if()) (NFC)
This commit is contained in:
commit
7bd2a7bde3
|
@ -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>());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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>();
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue