diff options
author | Erik Johnston <erik@matrix.org> | 2015-08-26 11:12:25 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-08-26 11:12:25 +0100 |
commit | efdaa5dd55f8b3d3c3ca8d80382fc4a19f6abbdb (patch) | |
tree | b23978ffedba7b45aa092c85314fe0682f5f2653 | |
parent | Bump changelog and version (diff) | |
parent | Remove needless existence checks (diff) | |
download | synapse-efdaa5dd55f8b3d3c3ca8d80382fc4a19f6abbdb.tar.xz |
Merge pull request #252 from matrix-org/erikj/typing_loop
Don't loop over all rooms ever in typing.get_new_events_for_user
-rw-r--r-- | synapse/handlers/typing.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/synapse/handlers/typing.py b/synapse/handlers/typing.py index 026bd2b9d4..d7096aab8c 100644 --- a/synapse/handlers/typing.py +++ b/synapse/handlers/typing.py @@ -204,15 +204,11 @@ class TypingNotificationHandler(BaseHandler): ) def _push_update_local(self, room_id, user, typing): - if room_id not in self._room_serials: - self._room_serials[room_id] = 0 - self._room_typing[room_id] = set() - - room_set = self._room_typing[room_id] + room_set = self._room_typing.setdefault(room_id, set()) if typing: room_set.add(user) - elif user in room_set: - room_set.remove(user) + else: + room_set.discard(user) self._latest_room_serial += 1 self._room_serials[room_id] = self._latest_room_serial @@ -260,8 +256,8 @@ class TypingNotificationEventSource(object): ) events = [] - for room_id in handler._room_serials: - if room_id not in joined_room_ids: + for room_id in joined_room_ids: + if room_id not in handler._room_serials: continue if handler._room_serials[room_id] <= from_key: continue |