]> granicus.if.org Git - ejabberd/commitdiff
Simple optimization in get_room_occupants_number command (#1964)
authorBadlop <badlop@process-one.net>
Thu, 7 Sep 2017 16:32:26 +0000 (18:32 +0200)
committerBadlop <badlop@process-one.net>
Thu, 7 Sep 2017 16:32:26 +0000 (18:32 +0200)
src/mod_muc_admin.erl

index e13c46e256f40550f2cf3174304b3fdb33d9e352..a8dbc24791c6fb66a74a5f44d81525991c9ef31d 100644 (file)
@@ -802,7 +802,13 @@ get_room_occupants(Pid) ->
       dict:to_list(S#state.users)).
 
 get_room_occupants_number(Room, Host) ->
-    length(get_room_occupants(Room, Host)).
+    case get_room_pid(Room, Host) of
+       room_not_found ->
+           throw({error, room_not_found});
+       Pid ->
+           S = get_room_state(Pid),
+           dict:size(S#state.users)
+    end.
 
 %%----------------------------
 %% Send Direct Invitation