mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Small optimization in mod_roster_sql:get_roster
This commit is contained in:
parent
32cf44827d
commit
bf068f5659
@ -80,9 +80,10 @@ get_roster(LUser, LServer) ->
|
|||||||
[]
|
[]
|
||||||
end,
|
end,
|
||||||
GroupsDict = lists:foldl(fun({J, G}, Acc) ->
|
GroupsDict = lists:foldl(fun({J, G}, Acc) ->
|
||||||
dict:append(J, G, Acc)
|
Gs = maps:get(J, Acc, []),
|
||||||
|
maps:put(J, [G | Gs], Acc)
|
||||||
end,
|
end,
|
||||||
dict:new(), JIDGroups),
|
maps:new(), JIDGroups),
|
||||||
{ok, lists:flatmap(
|
{ok, lists:flatmap(
|
||||||
fun(I) ->
|
fun(I) ->
|
||||||
case raw_to_record(LServer, I) of
|
case raw_to_record(LServer, I) of
|
||||||
@ -90,10 +91,7 @@ get_roster(LUser, LServer) ->
|
|||||||
error -> [];
|
error -> [];
|
||||||
R ->
|
R ->
|
||||||
SJID = jid:encode(R#roster.jid),
|
SJID = jid:encode(R#roster.jid),
|
||||||
Groups = case dict:find(SJID, GroupsDict) of
|
Groups = maps:get(SJID, GroupsDict, []),
|
||||||
{ok, Gs} -> Gs;
|
|
||||||
error -> []
|
|
||||||
end,
|
|
||||||
[R#roster{groups = Groups}]
|
[R#roster{groups = Groups}]
|
||||||
end
|
end
|
||||||
end, Items)};
|
end, Items)};
|
||||||
|
Loading…
Reference in New Issue
Block a user