aboutsummaryrefslogtreecommitdiff
path: root/src/mod_roster_sql.erl
diff options
context:
space:
mode:
authorAlexey Shchepin <alexey@process-one.net>2021-09-21 12:10:00 +0300
committerAlexey Shchepin <alexey@process-one.net>2021-09-21 12:10:00 +0300
commitbf068f56591bc84f360a8d600c157520e821425f (patch)
tree74d6bbacfddc7e5cdd14cabc89cf70cda6e9f72c /src/mod_roster_sql.erl
parentUse INSERT ... ON CONFLICT in SQL_UPSERT for PostgreSQL >= 9.5 (diff)
Small optimization in mod_roster_sql:get_roster
Diffstat (limited to 'src/mod_roster_sql.erl')
-rw-r--r--src/mod_roster_sql.erl10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/mod_roster_sql.erl b/src/mod_roster_sql.erl
index 76ddb29dd..ebfcde463 100644
--- a/src/mod_roster_sql.erl
+++ b/src/mod_roster_sql.erl
@@ -80,9 +80,10 @@ get_roster(LUser, LServer) ->
[]
end,
GroupsDict = lists:foldl(fun({J, G}, Acc) ->
- dict:append(J, G, Acc)
+ Gs = maps:get(J, Acc, []),
+ maps:put(J, [G | Gs], Acc)
end,
- dict:new(), JIDGroups),
+ maps:new(), JIDGroups),
{ok, lists:flatmap(
fun(I) ->
case raw_to_record(LServer, I) of
@@ -90,10 +91,7 @@ get_roster(LUser, LServer) ->
error -> [];
R ->
SJID = jid:encode(R#roster.jid),
- Groups = case dict:find(SJID, GroupsDict) of
- {ok, Gs} -> Gs;
- error -> []
- end,
+ Groups = maps:get(SJID, GroupsDict, []),
[R#roster{groups = Groups}]
end
end, Items)};