Skip to content

Commit

Permalink
Minor code simplification (ToMap instead of section->GetKeys)
Browse files Browse the repository at this point in the history
See #18442
  • Loading branch information
hrydgard committed Dec 28, 2023
1 parent a094637 commit 99962b9
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit 99962b9

Please sign in to comment.