From 2aa35ba40d4868d6e65f07b743b269c89d6b0e46 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 26 Feb 2009 02:26:30 +0000 Subject: core.xmlhandlers: Optimise completed stanza logic --- core/xmlhandlers.lua | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'core/xmlhandlers.lua') diff --git a/core/xmlhandlers.lua b/core/xmlhandlers.lua index 020e08db..56115917 100644 --- a/core/xmlhandlers.lua +++ b/core/xmlhandlers.lua @@ -121,17 +121,19 @@ function init_xmlhandlers(session, stream_callbacks) 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; -- cgit v1.2.3 From 219c84da4a2f42938e84ad60b53fbf1ed98954b8 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 27 Feb 2009 04:42:06 +0000 Subject: core.xmlhandlers: Remove redundant check in condition --- core/xmlhandlers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/xmlhandlers.lua') diff --git a/core/xmlhandlers.lua b/core/xmlhandlers.lua index 56115917..ea136c8d 100644 --- a/core/xmlhandlers.lua +++ b/core/xmlhandlers.lua @@ -122,7 +122,7 @@ function init_xmlhandlers(session, stream_callbacks) end end if stanza then - if stanza and #chardata > 0 then + if #chardata > 0 then -- We have some character data in the buffer stanza:text(t_concat(chardata)); chardata = {}; -- cgit v1.2.3