aboutsummaryrefslogtreecommitdiffstats
path: root/util/stanza.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2011-02-19 02:31:06 +0000
committerMatthew Wild <mwild1@gmail.com>2011-02-19 02:31:06 +0000
commit9d5e9921e6945b5dd7e0d70d8e340a74f018f574 (patch)
treeaabee61aabc8c6a4b44bd1e465afd7cd44ca1908 /util/stanza.lua
parent404c107e3fd464e5bb35b792eb4a13ac22071afa (diff)
downloadprosody-9d5e9921e6945b5dd7e0d70d8e340a74f018f574.tar.gz
prosody-9d5e9921e6945b5dd7e0d70d8e340a74f018f574.zip
util.stanza: Clean up matching_tags() and replace :childtags() with it
Diffstat (limited to 'util/stanza.lua')
-rw-r--r--util/stanza.lua27
1 files changed, 9 insertions, 18 deletions
diff --git a/util/stanza.lua b/util/stanza.lua
index 7d1f5693..ca79a728 100644
--- a/util/stanza.lua
+++ b/util/stanza.lua
@@ -138,29 +138,20 @@ function stanza_mt:children()
end, self, i;
end
-function stanza_mt:matching_tags(name, xmlns)
+function stanza_mt:childtags(name, xmlns)
xmlns = xmlns or self.attr.xmlns;
local tags = self.tags;
local start_i, max_i = 1, #tags;
return function ()
- for i=start_i,max_i do
- v = tags[i];
- if (not name or v.name == name)
- and (not xmlns or xmlns == v.attr.xmlns) then
- start_i = i+1;
- return v;
- end
+ for i = start_i, max_i do
+ local v = tags[i];
+ if (not name or v.name == name)
+ and (not xmlns or xmlns == v.attr.xmlns) then
+ start_i = i+1;
+ return v;
end
- end, tags, i;
-end
-
-function stanza_mt:childtags()
- local i = 0;
- return function (a)
- i = i + 1
- local v = self.tags[i]
- if v then return v; end
- end, self.tags[1], i;
+ end
+ end;
end
function stanza_mt:maptags(callback)