core.xmlhandlers: Optimise completed stanza logic

Thu, 26 Feb 2009 02:26:30 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Thu, 26 Feb 2009 02:26:30 +0000
changeset 838
1035846d6273
parent 837
86d14e7ef60c
child 839
c45b5072f773

core.xmlhandlers: Optimise completed stanza logic

core/xmlhandlers.lua file | annotate | diff | comparison | revisions
--- a/core/xmlhandlers.lua	Thu Feb 26 02:24:12 2009 +0000
+++ b/core/xmlhandlers.lua	Thu Feb 26 02:26:30 2009 +0000
@@ -121,17 +121,19 @@
 					cb_error(session, "parse-error", "unexpected-element-close", name);
 				end
 			end
-			if stanza and #chardata > 0 then
-				-- We have some character data in the buffer
-				stanza:text(t_concat(chardata));
-				chardata = {};
-			end
-			-- Complete stanza
-			if #stanza.last_add == 0 then
-				cb_handlestanza(session, stanza);
-				stanza = nil;
-			else
-				stanza:up();
+			if stanza then
+				if stanza and #chardata > 0 then
+					-- We have some character data in the buffer
+					stanza:text(t_concat(chardata));
+					chardata = {};
+				end
+				-- Complete stanza
+				if #stanza.last_add == 0 then
+					cb_handlestanza(session, stanza);
+					stanza = nil;
+				else
+					stanza:up();
+				end
 			end
 		end
 	return xml_handlers;

mercurial