summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authormitaclaw <140017135+mitaclaw@users.noreply.github.com>2024-09-28 20:18:33 -0700
committermitaclaw <140017135+mitaclaw@users.noreply.github.com>2024-10-17 18:38:34 -0700
commitbe0b13da97121d9ca1b1d454cf3a36bcccb5173b (patch)
tree90c2956e694b6ba5750f4df022b3201c3f6b0539 /Source/Core
parent4fde0f2868212afc216cd9324af8d5efcc282887 (diff)
Simplify `std::remove` with `std::erase`
`std::erase` is a replacement for the remove-erase idiom. Changes to `OpenModeToAndroid` inadvertently revealed that the prior implementation had UB (potentially deleting the end iterator). This is now fixed.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DolphinQt/Settings.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/Source/Core/DolphinQt/Settings.cpp b/Source/Core/DolphinQt/Settings.cpp
index 8d4a3513b9..938e892962 100644
--- a/Source/Core/DolphinQt/Settings.cpp
+++ b/Source/Core/DolphinQt/Settings.cpp
@@ -309,11 +309,9 @@ void Settings::RemovePath(const QString& qpath)
std::string path = qpath.toStdString();
std::vector<std::string> paths = Config::GetIsoPaths();
- auto new_end = std::remove(paths.begin(), paths.end(), path);
- if (new_end == paths.end())
+ if (std::erase(paths, path) == 0)
return;
- paths.erase(new_end, paths.end());
Config::SetIsoPaths(paths);
emit PathRemoved(qpath);
}