Software /
code /
prosody
Comparison
plugins/mod_roster.lua @ 3323:5228a395999b
mod_roster: Use value returned by pairs() during roster iteration to avoid dozens of wasteful table lookups
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 05 Jul 2010 02:20:37 +0100 |
parent | 2925:692b3c6c5bd2 |
child | 3525:1e44e7e8e79c |
comparison
equal
deleted
inserted
replaced
3322:c4e107e7c883 | 3323:5228a395999b |
---|---|
40 local server_ver = tonumber(session.roster[false].version or 1); | 40 local server_ver = tonumber(session.roster[false].version or 1); |
41 | 41 |
42 if not (client_ver and server_ver) or client_ver ~= server_ver then | 42 if not (client_ver and server_ver) or client_ver ~= server_ver then |
43 roster:query("jabber:iq:roster"); | 43 roster:query("jabber:iq:roster"); |
44 -- Client does not support versioning, or has stale roster | 44 -- Client does not support versioning, or has stale roster |
45 for jid in pairs(session.roster) do | 45 for jid, item in pairs(session.roster) do |
46 if jid ~= "pending" and jid then | 46 if jid ~= "pending" and jid then |
47 roster:tag("item", { | 47 roster:tag("item", { |
48 jid = jid, | 48 jid = jid, |
49 subscription = session.roster[jid].subscription, | 49 subscription = item.subscription, |
50 ask = session.roster[jid].ask, | 50 ask = item.ask, |
51 name = session.roster[jid].name, | 51 name = item.name, |
52 }); | 52 }); |
53 for group in pairs(session.roster[jid].groups) do | 53 for group in pairs(item.groups) do |
54 roster:tag("group"):text(group):up(); | 54 roster:tag("group"):text(group):up(); |
55 end | 55 end |
56 roster:up(); -- move out from item | 56 roster:up(); -- move out from item |
57 end | 57 end |
58 end | 58 end |