[System/Core] Simplify loops

This commit is contained in:
Herman Semenov 2024-04-03 19:25:55 +03:00
parent 8aac45fec0
commit 4b92848bdc
2 changed files with 14 additions and 18 deletions

View File

@ -261,20 +261,20 @@ void OnScreenDisplay::SetProgressBar(std::string_view id, std::string_view messa
void OnScreenDisplay::RemoveProgressBar(const std::string &id, bool success, float delay_s) {
std::lock_guard<std::mutex> guard(mutex_);
for (auto iter = entries_.begin(); iter != entries_.end(); iter++) {
if (iter->type == OSDType::PROGRESS_BAR && iter->id == id) {
for (auto &ent : entries_) {
if (ent.type == OSDType::PROGRESS_BAR && ent.id == id) {
if (success) {
// Quickly shoot up to max, if we weren't there.
if (iter->maxValue != 0.0f) {
iter->progress = iter->maxValue;
if (ent.maxValue != 0.0f) {
ent.progress = ent.maxValue;
} else {
// Fake a full progress
iter->minValue = 0;
iter->maxValue = 1;
iter->progress = 1;
ent.minValue = 0;
ent.maxValue = 1;
ent.progress = 1;
}
}
iter->endTime = time_now_d() + delay_s + FadeoutTime();
ent.endTime = time_now_d() + delay_s + FadeoutTime();
break;
}
}

View File

@ -1514,16 +1514,12 @@ void Config::RemoveRecent(const std::string &file) {
private_->ResetRecentIsosThread();
std::lock_guard<std::mutex> guard(private_->recentIsosLock);
const std::string filename = File::ResolvePath(file);
for (auto iter = recentIsos.begin(); iter != recentIsos.end();) {
const std::string recent = File::ResolvePath(*iter);
if (filename == recent) {
// Note that the increment-erase idiom doesn't work with vectors.
iter = recentIsos.erase(iter);
} else {
iter++;
}
}
const auto &filename = File::ResolvePath(file);
std::remove_if(recentIsos.begin(), recentIsos.end(), [filename](const auto &str) {
const auto &recent = File::ResolvePath(str);
return filename == recent;
});
}
void Config::CleanRecent() {