/soc/2015/koosha/main: 55b339c4feda: XEP-0184: remove the nested...

Koosha Khajehmoogahi koosha at posteo.de
Sat Jun 27 10:48:44 EDT 2015


Changeset: 55b339c4feda6274c555a3aa03e880b878c5e004
Author:	 Koosha Khajehmoogahi <koosha at posteo.de>
Date:	 2015-06-27 16:47 +0200
Branch:	 default
URL: https://hg.pidgin.im/soc/2015/koosha/main/rev/55b339c4feda

Description:

XEP-0184: remove the nested loop when parsing incoming message

diffstat:

 libpurple/protocols/jabber/message.c |  19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)

diffs (39 lines):

diff --git a/libpurple/protocols/jabber/message.c b/libpurple/protocols/jabber/message.c
--- a/libpurple/protocols/jabber/message.c
+++ b/libpurple/protocols/jabber/message.c
@@ -598,7 +598,7 @@ void jabber_message_parse(JabberStream *
 {
 	JabberMessage *jm;
 	const char *id, *from, *to, *type;
-	PurpleXmlNode *child, *sibling;
+	PurpleXmlNode *child;
 	gboolean signal_return;
 
 	from = purple_xmlnode_get_attrib(packet, "from");
@@ -687,22 +687,13 @@ void jabber_message_parse(JabberStream *
 				char *msg = purple_xmlnode_get_data(child);
 				char *escaped = purple_markup_escape_text(msg, -1);
 				jm->body = purple_strdup_withhtml(escaped);
-				if (jm->type == JABBER_MESSAGE_NORMAL ||
-				    jm->type == JABBER_MESSAGE_CHAT)
-				{
-					for (sibling = packet->child; sibling; sibling = sibling->next) {
-						if (!strcmp(sibling->name, "request")) {
-							const char *sibling_xmlns = purple_xmlnode_get_namespace(sibling);
-							if (!strcmp(sibling_xmlns, "urn:xmpp:receipts")) {
-								jm->receipt = TRUE;
-								break;
-							}
-						}
-					}
-				}
 				g_free(escaped);
 				g_free(msg);
 			}
+		} else if(!strcmp(child->name, "request") && !strcmp(purple_xmlnode_get_namespace(child), "urn:xmpp:receipts")) {
+			if (jm->type == JABBER_MESSAGE_NORMAL || jm->type == JABBER_MESSAGE_CHAT) {
+				jm->receipt = TRUE;
+			}
 		} else if(!strcmp(child->name, "html") && !strcmp(xmlns, NS_XHTML_IM)) {
 			if(!jm->xhtml && purple_xmlnode_get_child(child, "body")) {
 				char *c;



More information about the Commits mailing list