mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-15 06:58:37 +02:00
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.
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user