From 19dc6cadea0168f72daff7c0ed679ccdac71a7d5 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Wed, 29 Dec 2021 06:01:38 +0100 Subject: Reserve size of some containers we are filling --- src/ui/NhekoGlobalObject.cpp | 4 ++-- src/ui/RoomSettings.cpp | 6 ++++-- src/ui/UserProfile.cpp | 19 ++++++++++--------- 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'src/ui') diff --git a/src/ui/NhekoGlobalObject.cpp b/src/ui/NhekoGlobalObject.cpp index b6122ac9..56c0d9f0 100644 --- a/src/ui/NhekoGlobalObject.cpp +++ b/src/ui/NhekoGlobalObject.cpp @@ -28,8 +28,8 @@ void Nheko::updateUserProfile() { if (cache::client() && cache::client()->isInitialized()) - currentUser_.reset( - new UserProfile(QLatin1String(""), utils::localUser(), ChatPage::instance()->timelineManager())); + currentUser_.reset(new UserProfile( + QLatin1String(""), utils::localUser(), ChatPage::instance()->timelineManager())); else currentUser_.reset(); emit profileChanged(); diff --git a/src/ui/RoomSettings.cpp b/src/ui/RoomSettings.cpp index 038c2e89..b9042524 100644 --- a/src/ui/RoomSettings.cpp +++ b/src/ui/RoomSettings.cpp @@ -234,8 +234,10 @@ RoomSettings::roomName() const QString RoomSettings::roomTopic() const { - return utils::replaceEmoji(utils::linkifyMessage( - QString::fromStdString(info_.topic).toHtmlEscaped().replace(QLatin1String("\n"), QLatin1String("
")))); + return utils::replaceEmoji( + utils::linkifyMessage(QString::fromStdString(info_.topic) + .toHtmlEscaped() + .replace(QLatin1String("\n"), QLatin1String("
")))); } QString diff --git a/src/ui/UserProfile.cpp b/src/ui/UserProfile.cpp index cd9e170d..19bbb007 100644 --- a/src/ui/UserProfile.cpp +++ b/src/ui/UserProfile.cpp @@ -232,6 +232,7 @@ UserProfile::updateVerificationStatus() this->isUserVerified = verificationStatus.user_verified; emit userStatusChanged(); + deviceInfo.reserve(devices.size()); for (const auto &d : devices) { auto device = d.second; verification::Status verified = @@ -244,9 +245,9 @@ UserProfile::updateVerificationStatus() if (isSelf() && device.device_id == ::http::client()->device_id()) verified = verification::Status::SELF; - deviceInfo.push_back({QString::fromStdString(d.first), - QString::fromStdString(device.unsigned_info.device_display_name), - verified}); + deviceInfo.emplace_back(QString::fromStdString(d.first), + QString::fromStdString(device.unsigned_info.device_display_name), + verified); } // For self, also query devices without keys @@ -270,17 +271,17 @@ UserProfile::updateVerificationStatus() found = true; // Gottem! Let's fill in the blanks e.lastIp = QString::fromStdString(d.last_seen_ip); - e.lastTs = d.last_seen_ts; + e.lastTs = static_cast(d.last_seen_ts); break; } } // No entry? Let's add one. if (!found) { - deviceInfo.push_back({QString::fromStdString(d.device_id), - QString::fromStdString(d.display_name), - verification::NOT_APPLICABLE, - QString::fromStdString(d.last_seen_ip), - d.last_seen_ts}); + deviceInfo.emplace_back(QString::fromStdString(d.device_id), + QString::fromStdString(d.display_name), + verification::NOT_APPLICABLE, + QString::fromStdString(d.last_seen_ip), + d.last_seen_ts); } } -- cgit 1.5.1