[network/ruqola] src/core/messages: Avoid multi copy

Laurent Montel <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 6b686f44e4207d434a85a02e0b915cb95d0a54b2 by Laurent Montel.
Committed on 13/08/2026 at 19:39.
Pushed by mlaurent into branch 'master'.

Avoid multi copy

M  +2    -2    src/core/messages/block/blocks.cpp
M  +2    -2    src/core/messages/channels.cpp
M  +2    -2    src/core/messages/messageattachments.cpp
M  +2    -2    src/core/messages/messageurls.cpp
M  +5    -5    src/core/messages/reactions.cpp

https://invent.kde.org/network/ruqola/-/commit/6b686f44e4207d434a85a02e0b915cb95d0a54b2

diff --git a/src/core/messages/block/blocks.cpp b/src/core/messages/block/blocks.cpp
index 43e5cba88e..caddd361be 100644
--- a/src/core/messages/block/blocks.cpp
+++ b/src/core/messages/block/blocks.cpp
@@ -77,8 +77,8 @@ bool Blocks::operator==(const Blocks &other) const
 
 QDebug operator<<(QDebug d, const Blocks &t)
 {
-    for (int i = 0; i < t.blocks().count(); i++) {
-        d.space() << t.blocks().at(i) << "\n";
+    for (const Block &block : t.blocks()) {
+        d.space() << block << "\n";
     }
     return d;
 }
diff --git a/src/core/messages/channels.cpp b/src/core/messages/channels.cpp
index c9c134ecda..a0eddbd998 100644
--- a/src/core/messages/channels.cpp
+++ b/src/core/messages/channels.cpp
@@ -62,8 +62,8 @@ bool Channels::operator==(const Channels &other) const
 
 QDebug operator<<(QDebug d, const Channels &t)
 {
-    for (int i = 0; i < t.channels().count(); i++) {
-        d.space() << t.channels().at(i) << "\n";
+    for (const Channels::ChannelInfo &info : t.channels()) {
+        d.space() << info << "\n";
     }
     return d;
 }
diff --git a/src/core/messages/messageattachments.cpp b/src/core/messages/messageattachments.cpp
index 96ddf182c5..006ba61d68 100644
--- a/src/core/messages/messageattachments.cpp
+++ b/src/core/messages/messageattachments.cpp
@@ -61,8 +61,8 @@ bool MessageAttachments::operator==(const MessageAttachments &other) const
 
 QDebug operator<<(QDebug d, const MessageAttachments &t)
 {
-    for (int i = 0; i < t.messageAttachments().count(); i++) {
-        d.space() << t.messageAttachments().at(i) << "\n";
+    for (const MessageAttachment &attachment : t.messageAttachments()) {
+        d.space() << attachment << "\n";
     }
     return d;
 }
diff --git a/src/core/messages/messageurls.cpp b/src/core/messages/messageurls.cpp
index 04e2514235..b6499e3456 100644
--- a/src/core/messages/messageurls.cpp
+++ b/src/core/messages/messageurls.cpp
@@ -61,8 +61,8 @@ bool MessageUrls::operator==(const MessageUrls &other) const
 
 QDebug operator<<(QDebug d, const MessageUrls &t)
 {
-    for (int i = 0; i < t.messageUrls().count(); i++) {
-        d.space() << t.messageUrls().at(i) << "\n";
+    for (const MessageUrl &url : t.messageUrls()) {
+        d.space() << url << "\n";
     }
     return d;
 }
diff --git a/src/core/messages/reactions.cpp b/src/core/messages/reactions.cpp
index ef5fbdd636..fd82f946e0 100644
--- a/src/core/messages/reactions.cpp
+++ b/src/core/messages/reactions.cpp
@@ -71,8 +71,8 @@ bool Reactions::operator==(const Reactions &other) const
 
 QDebug operator<<(QDebug d, const Reactions &t)
 {
-    for (int i = 0; i < t.reactions().count(); i++) {
-        d.space() << t.reactions().at(i) << "\n";
+    for (const Reaction &reaction : t.reactions()) {
+        d.space() << reaction << "\n";
     }
     return d;
 }
@@ -80,10 +80,10 @@ QDebug operator<<(QDebug d, const Reactions &t)
 QJsonObject Reactions::serialize(const Reactions &reactions)
 {
     QJsonObject obj;
-    for (int i = 0; i < reactions.reactions().count(); ++i) {
+    for (const Reaction &reaction : reactions.reactions()) {
         QJsonObject react;
-        react["usernames"_L1] = QJsonArray::fromStringList(reactions.reactions().at(i).userNames());
-        obj[reactions.reactions().at(i).reactionName()] = react;
+        react["usernames"_L1] = QJsonArray::fromStringList(reaction.userNames());
+        obj[reaction.reactionName()] = react;
     }
     return obj;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.