Change raw loop to std::algorithm find_if

sql-rework
Tomasz Golinski 2020-02-16 19:06:23 +01:00
rodzic 3785d5d067
commit 397eaf415f
1 zmienionych plików z 3 dodań i 6 usunięć

Wyświetl plik

@ -4,6 +4,7 @@
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <curl/curl.h>
#include <nlohmann/json.hpp>
@ -162,12 +163,8 @@ Caches Okapi::get_caches(const std::map<std::string, std::tm>& codes) const {
c.set_date_hidden(tmp);
//ugly way to handle date... might produce bad results if a cache appears twice in the list
for (auto& el2 : codes) {
if (el2.first == c.code) {
c.set_date(el2.second);
break;
}
}
auto el2 = std::find_if( codes.begin(), codes.end(), [&](auto& e) { return e.first == c.code; });
c.set_date(el2->second);
cc.insert(c);
}
}