# HG changeset patch # User Waqas Hussain # Date 1327474452 -18000 # Node ID 0da4e0f0f0effa43b0c8ab242f0132f7fbeb539c # Parent 1dbd06eedaa4662713f9a67013a927441114e1f9 util.xmppstream: Optimize attribute processing. diff -r 1dbd06eedaa4 -r 0da4e0f0f0ef util/xmppstream.lua --- a/util/xmppstream.lua Wed Jan 25 11:49:27 2012 +0500 +++ b/util/xmppstream.lua Wed Jan 25 11:54:12 2012 +0500 @@ -25,8 +25,11 @@ local new_parser = lxp.new; -local ns_prefixes = { - ["http://www.w3.org/XML/1998/namespace"] = "xml"; +local xml_namespace = { + ["http://www.w3.org/XML/1998/namespace\1lang"] = "xml:lang"; + ["http://www.w3.org/XML/1998/namespace\1space"] = "xml:space"; + ["http://www.w3.org/XML/1998/namespace\1base"] = "xml:base"; + ["http://www.w3.org/XML/1998/namespace\1id"] = "xml:id"; }; local xmlns_streams = "http://etherx.jabber.org/streams"; @@ -73,17 +76,13 @@ non_streamns_depth = non_streamns_depth + 1; end - -- FIXME !!!!! for i=1,#attr do local k = attr[i]; attr[i] = nil; - local ns, nm = k:match(ns_pattern); - if nm ~= "" then - ns = ns_prefixes[ns]; - if ns then - attr[ns..":"..nm] = attr[k]; - attr[k] = nil; - end + local xmlk = xml_namespace[k]; + if xmlk then + attr[xmlk] = attr[k]; + attr[k] = nil; end end