Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Speed up get_joined_hosts #2228

Merged
merged 1 commit into from
May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion synapse/handlers/room_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,10 +739,11 @@ def _is_host_in_room(self, current_state_ids):
if len(current_state_ids) == 1 and create_event_id:
defer.returnValue(self.hs.is_mine_id(create_event_id))

for (etype, state_key), event_id in current_state_ids.items():
for etype, state_key in current_state_ids:
if etype != EventTypes.Member or not self.hs.is_mine_id(state_key):
continue

event_id = current_state_ids[(etype, state_key)]
event = yield self.store.get_event(event_id, allow_none=True)
if not event:
continue
Expand Down
3 changes: 2 additions & 1 deletion synapse/storage/roommember.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def _get_joined_hosts(self, room_id, state_group, current_state_ids):
assert state_group is not None

joined_hosts = set()
for (etype, state_key), event_id in current_state_ids.items():
for etype, state_key in current_state_ids:
if etype == EventTypes.Member:
try:
host = get_domain_from_id(state_key)
Expand All @@ -545,6 +545,7 @@ def _get_joined_hosts(self, room_id, state_group, current_state_ids):
if host in joined_hosts:
continue

event_id = current_state_ids[(etype, state_key)]
event = yield self.get_event(event_id, allow_none=True)
if event and event.content["membership"] == Membership.JOIN:
joined_hosts.add(intern_string(host))
Expand Down