25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-24 17:29:28 +01:00

Optimized mod_roster_odbc:get_roster

This commit is contained in:
Alexey Shchepin 2011-06-29 11:56:23 +03:00
parent 41fad8956b
commit 60009ece44

View File

@ -249,6 +249,11 @@ get_roster(LUser, LServer) ->
_ ->
[]
end,
GroupsDict =
lists:foldl(
fun({J, G}, Acc) ->
dict:append(J, G, Acc)
end, dict:new(), JIDGroups),
RItems = lists:flatmap(
fun(I) ->
case raw_to_record(LServer, I) of
@ -257,12 +262,11 @@ get_roster(LUser, LServer) ->
[];
R ->
SJID = jlib:jid_to_string(R#roster.jid),
Groups = lists:flatmap(
fun({S, G}) when S == SJID ->
[G];
(_) ->
[]
end, JIDGroups),
Groups =
case dict:find(SJID, GroupsDict) of
{ok, Gs} -> Gs;
error -> []
end,
[R#roster{groups = Groups}]
end
end, Items),