24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-04 21:27:16 +02:00

Optimized mod_roster_odbc:get_roster

This commit is contained in:
Alexey Shchepin 2011-06-29 11:56:23 +03:00
parent d673ff5fad
commit 15f664af26

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),