Software /
code /
prosody
Changeset
4168:4919831b5b56
util.stanza: Clean up matching_tags() and replace :childtags() with it
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 19 Feb 2011 02:31:06 +0000 |
parents | 4143:eccd3c87d717 |
children | 4169:1033729a2467 |
files | util/stanza.lua |
diffstat | 1 files changed, 9 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/util/stanza.lua Sun Feb 13 22:57:17 2011 +0000 +++ b/util/stanza.lua Sat Feb 19 02:31:06 2011 +0000 @@ -138,29 +138,20 @@ 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)