Diff

core/xmlhandlers.lua @ 838:1035846d6273

core.xmlhandlers: Optimise completed stanza logic
author Matthew Wild <mwild1@gmail.com>
date Thu, 26 Feb 2009 02:26:30 +0000
parent 760:90ce865eebd8
child 844:503ca8da1000
line wrap: on
line diff
--- 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;