diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2023-01-31 21:04:59 +0100 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2023-01-31 21:05:23 +0100 |
commit | ee5b33978a71ea794bd359e59b628baf39d39bb9 (patch) | |
tree | 368305e0a50d3a76de2dc86b98b30467ef74fff7 /src/UsersModel.cpp | |
parent | 8c06460e91e1f2462f3645e853e01d498c37ad39 (diff) |
Optimize user model construction by 2.5x
Diffstat (limited to 'src/UsersModel.cpp')
-rw-r--r-- | src/UsersModel.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/UsersModel.cpp b/src/UsersModel.cpp index 5dc3b3f1..3bdb455a 100644 --- a/src/UsersModel.cpp +++ b/src/UsersModel.cpp @@ -34,12 +34,15 @@ UsersModel::UsersModel(const std::string &roomId, QObject *parent) } } } else { - for (const auto &m : cache::roomMembers(roomId)) { - displayNames.push_back(QString::fromStdString(cache::displayName(room_id, m))); - userids.push_back(QString::fromStdString(m)); - avatarUrls.push_back( - cache::avatarUrl(QString::fromStdString(room_id), QString::fromStdString(m))); + const auto start_at = std::chrono::steady_clock::now(); + for (const auto &m : cache::getMembers(roomId, 0, -1)) { + displayNames.push_back(m.display_name); + userids.push_back(m.user_id); + avatarUrls.push_back(m.avatar_url); } + const auto end_at = std::chrono::steady_clock::now(); + const auto build_time = std::chrono::duration<double, std::milli>(end_at - start_at); + nhlog::ui()->debug("UsersModel: build data: {} ms", build_time.count()); } } |