Minor code simplification (ToMap instead of section->GetKeys)

See #18442
This commit is contained in:
Henrik Rydgård 2023-12-28 10:52:28 +01:00
parent a094637ab1
commit 99962b91e5

View file

@ -1893,19 +1893,14 @@ void PlayTimeTracker::Stop(const std::string &gameId) {
void PlayTimeTracker::Load(const Section *section) {
tracker_.clear();
std::vector<std::string> keys;
section->GetKeys(keys);
for (auto key : keys) {
std::string value;
if (!section->Get(key.c_str(), &value, nullptr)) {
continue;
}
auto map = section->ToMap();
for (const auto &iter : map) {
const std::string &value = iter.second;
// Parse the string.
PlayTime gameTime{};
if (2 == sscanf(value.c_str(), "%d,%llu", &gameTime.totalTimePlayed, (long long *)&gameTime.lastTimePlayed)) {
tracker_[key] = gameTime;
tracker_[iter.first.c_str()] = gameTime;
}
}
}