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

Commit

Permalink
Merge pull request #2228 from matrix-org/erikj/speed_up_get_hosts
Browse files Browse the repository at this point in the history
Speed up get_joined_hosts
  • Loading branch information
erikjohnston authored May 16, 2017
2 parents 7c69849 + 13f540e commit 6fa8148
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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

0 comments on commit 6fa8148

Please sign in to comment.