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/UserProfile.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/ui/UserProfile.cpp') 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