aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexey Shchepin <alexey@process-one.net>2011-06-29 11:56:23 +0300
committerAlexey Shchepin <alexey@process-one.net>2011-06-29 11:56:23 +0300
commit15f664af26b0711fc35dd0bf2130d7a0d74fb11f (patch)
tree20656db0a38c2c3a8bbaada8e8828da82d05010e /src
parentSupport servers that reply error on any command before registration (thanks t... (diff)
Optimized mod_roster_odbc:get_roster
Diffstat (limited to 'src')
-rw-r--r--src/mod_roster_odbc.erl16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mod_roster_odbc.erl b/src/mod_roster_odbc.erl
index 936d3cff2..b713a0aab 100644
--- a/src/mod_roster_odbc.erl
+++ b/src/mod_roster_odbc.erl
@@ -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),