Skip to content

Commit

Permalink
fix: slightly improve performance, but sadly still most of it goes on…
Browse files Browse the repository at this point in the history
… the curl requests
  • Loading branch information
hero622 committed Nov 1, 2023
1 parent 66b9262 commit c864b18
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Modules/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,17 +536,19 @@ DETOUR(Client::SetPanelStats) {
std::vector<std::pair<std::string, json11::Json>> times;
for (auto score : json) {
times.push_back(score);

std::sort(times.begin(), times.end(), [](std::pair<std::string, json11::Json> a, std::pair<std::string, json11::Json> b) {
return atoi(a.second["scoreData"]["score"].string_value().c_str()) < atoi(b.second["scoreData"]["score"].string_value().c_str());
});
}

std::sort(times.begin(), times.end(), [](std::pair<std::string, json11::Json> a, std::pair<std::string, json11::Json> b) {
return atoi(a.second["scoreData"]["score"].string_value().c_str()) < atoi(b.second["scoreData"]["score"].string_value().c_str());
});

auto pb = AutoSubmitMod::GetCurrentPbScore(*map_id);
int pb_idx = 0;
for (int i = 0; i < times.size(); ++i) {
if (atoi(times[i].second["scoreData"]["score"].string_value().c_str()) == *pb)
if (atoi(times[i].second["scoreData"]["score"].string_value().c_str()) == *pb) {
pb_idx = i;
break;
}
}

auto min = std::max(pb_idx - 3, 0);
Expand Down

0 comments on commit c864b18

Please sign in to comment.