diff --git a/include/ChatPage.h b/include/ChatPage.h index 5d7d280..5a6376c 100644 --- a/include/ChatPage.h +++ b/include/ChatPage.h @@ -206,7 +206,7 @@ ChatPage::updateUserMetadata(const std::vector &collection) { using Member = mtx::events::StateEvent; - for (auto &event : collection) { + for (const auto &event : collection) { if (mpark::holds_alternative(event)) { auto member = mpark::get(event); @@ -224,7 +224,7 @@ ChatPage::getMemberships(const std::vector &collection) const using Member = mtx::events::StateEvent; - for (auto &event : collection) { + for (const auto &event : collection) { if (mpark::holds_alternative(event)) { auto member = mpark::get(event); memberships.emplace(member.state_key, member); diff --git a/src/AvatarProvider.cc b/src/AvatarProvider.cc index 21253ba..1c509d0 100644 --- a/src/AvatarProvider.cc +++ b/src/AvatarProvider.cc @@ -36,7 +36,7 @@ AvatarProvider::updateAvatar(const QString &uid, const QImage &img) auto callbacks = toBeResolved_[uid]; // Update all the timeline items with the resolved avatar. - for (const auto callback : callbacks) + for (const auto &callback : callbacks) callback(img); toBeResolved_.erase(uid); diff --git a/src/Cache.cc b/src/Cache.cc index d889f73..8a58b63 100644 --- a/src/Cache.cc +++ b/src/Cache.cc @@ -482,7 +482,7 @@ Cache::readReceipts(const QString &event_id, const QString &room_id) auto json_response = json::parse(std::string(value.data(), value.size())); auto values = json_response.get>(); - for (auto v : values) + for (const auto &v : values) // timestamp, user_id receipts.emplace(v.second, v.first); } @@ -497,7 +497,7 @@ Cache::readReceipts(const QString &event_id, const QString &room_id) void Cache::updateReadReceipt(const std::string &room_id, const Receipts &receipts) { - for (auto receipt : receipts) { + for (const auto &receipt : receipts) { const auto event_id = receipt.first; auto event_receipts = receipt.second; @@ -528,7 +528,7 @@ Cache::updateReadReceipt(const std::string &room_id, const Receipts &receipts) } // Append the new ones. - for (auto event_receipt : event_receipts) + for (const auto &event_receipt : event_receipts) saved_receipts.emplace(event_receipt.first, event_receipt.second); // Save back the merged (or only the new) receipts. diff --git a/src/ChatPage.cc b/src/ChatPage.cc index a3ae742..2ef4cf4 100644 --- a/src/ChatPage.cc +++ b/src/ChatPage.cc @@ -531,7 +531,7 @@ ChatPage::initialSyncCompleted(const mtx::responses::Sync &response) roomSettings_.emplace(room_id, QSharedPointer(new RoomSettings(room_id))); - for (const auto membership : roomState->memberships) { + for (const auto &membership : roomState->memberships) { updateUserDisplayName(membership.second); updateUserAvatarUrl(membership.second); } @@ -791,7 +791,7 @@ ChatPage::updateTypingUsers(const QString &roomid, const std::vectorclear(); - for (auto receipt : receipts) { + for (const auto &receipt : receipts) { auto user = new ReceiptItem(this, QString::fromStdString(receipt.second), receipt.first); auto item = new QListWidgetItem(userList_);