# HG changeset patch # User Matthew Wild # Date 1235615190 0 # Node ID 1035846d62734fce9cd265d3f2742dda889d90be # Parent 86d14e7ef60ced873838a26104d7cbded5b4a1fe core.xmlhandlers: Optimise completed stanza logic diff -r 86d14e7ef60c -r 1035846d6273 core/xmlhandlers.lua --- 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;