From 4c9d6b4d7cb70ece5968b0a667fc6711886739c1 Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Mon, 26 Jan 2026 12:30:40 +0100 Subject: [PATCH] passing const ref when copy not needed --- Linphone/core/chat/ChatCore.cpp | 2 +- Linphone/core/chat/ChatCore.hpp | 2 +- Linphone/core/chat/message/ChatMessageCore.cpp | 2 +- Linphone/core/chat/message/EventLogList.cpp | 2 +- Linphone/tool/thread/SafeConnection.hpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Linphone/core/chat/ChatCore.cpp b/Linphone/core/chat/ChatCore.cpp index 6acd8dec..c39303a5 100644 --- a/Linphone/core/chat/ChatCore.cpp +++ b/Linphone/core/chat/ChatCore.cpp @@ -121,7 +121,7 @@ ChatCore::~ChatCore() { emit mChatModel->removeListener(); } -void ChatCore::setSelf(QSharedPointer me) { +void ChatCore::setSelf(const QSharedPointer &me) { mChatModelConnection = SafeConnection::create(me, mChatModel); mChatModelConnection->makeConnectToCore(&ChatCore::lDeleteHistory, [this]() { mChatModelConnection->invokeToModel([this]() { mChatModel->deleteHistory(); }); diff --git a/Linphone/core/chat/ChatCore.hpp b/Linphone/core/chat/ChatCore.hpp index ec7ee734..d8100cd7 100644 --- a/Linphone/core/chat/ChatCore.hpp +++ b/Linphone/core/chat/ChatCore.hpp @@ -74,7 +74,7 @@ public: static QSharedPointer create(const std::shared_ptr &chatRoom); ChatCore(const std::shared_ptr &chatRoom); ~ChatCore(); - void setSelf(QSharedPointer me); + void setSelf(const QSharedPointer &me); QDateTime getLastUpdatedTime() const; void setLastUpdatedTime(QDateTime time); diff --git a/Linphone/core/chat/message/ChatMessageCore.cpp b/Linphone/core/chat/message/ChatMessageCore.cpp index ff1dbe9f..c85dea4f 100644 --- a/Linphone/core/chat/message/ChatMessageCore.cpp +++ b/Linphone/core/chat/message/ChatMessageCore.cpp @@ -157,7 +157,7 @@ ChatMessageCore::ChatMessageCore(const std::shared_ptr &c mTotalReactionsLabel = tr("all_reactions_label"); auto reac = chatmessage->getOwnReaction(); mOwnReaction = reac ? Utils::coreStringToAppString(reac->getBody()) : QString(); - for (auto &reaction : chatmessage->getReactions()) { + for (const auto &reaction : chatmessage->getReactions()) { if (reaction) { auto fromAddr = reaction->getFromAddress()->clone(); fromAddr->clean(); diff --git a/Linphone/core/chat/message/EventLogList.cpp b/Linphone/core/chat/message/EventLogList.cpp index ab10ab7a..18be0c57 100644 --- a/Linphone/core/chat/message/EventLogList.cpp +++ b/Linphone/core/chat/message/EventLogList.cpp @@ -91,7 +91,7 @@ void EventLogList::setChatCore(QSharedPointer core) { connect(mChatCore.get(), &ChatCore::eventListCleared, this, [this] { resetData(); }); connect(mChatCore.get(), &ChatCore::eventsInserted, this, [this](QList> list) { auto eventsList = getSharedList(); - for (auto &event : list) { + for (const auto &event : list) { auto it = std::find_if(eventsList.begin(), eventsList.end(), [event](const QSharedPointer item) { return item == event; }); if (it == eventsList.end()) { diff --git a/Linphone/tool/thread/SafeConnection.hpp b/Linphone/tool/thread/SafeConnection.hpp index 15fd91ff..854c6793 100644 --- a/Linphone/tool/thread/SafeConnection.hpp +++ b/Linphone/tool/thread/SafeConnection.hpp @@ -66,7 +66,7 @@ template class SafeConnection : public QObject { // Use create functions. protected: - SafeConnection(QSharedPointer a, std::shared_ptr b) + SafeConnection(const QSharedPointer &a, std::shared_ptr b) : mCore(a), mModel(b), mCoreObject(a.get()), mModelObject(b.get()) { } SafeConnection(QSharedPointer a, QSharedPointer b)