diff options
author | Erik Johnston <erik@matrix.org> | 2024-07-30 12:49:25 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2024-07-30 12:49:25 +0100 |
commit | 9284cc0110bb8bdcf0b9a6852cd511a345455009 (patch) | |
tree | 4f3146fbdaab3c9318c7c272c480e6157dfdd942 | |
parent | Refactor to make LIVE non-static value (diff) | |
download | synapse-9284cc0110bb8bdcf0b9a6852cd511a345455009.tar.xz |
Add fast path if from_token is None
-rw-r--r-- | synapse/handlers/sliding_sync.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/synapse/handlers/sliding_sync.py b/synapse/handlers/sliding_sync.py index 6ddc8ff87b..b1bede894d 100644 --- a/synapse/handlers/sliding_sync.py +++ b/synapse/handlers/sliding_sync.py @@ -2354,18 +2354,21 @@ class SlidingSyncConnectionStore: # given token, so we don't need to update the entry. # - NEVER: We have never previously sent down the room, and we haven't # sent anything down this time either so we leave it as NEVER. + # + # We only need to do this if `from_token` is not None, as if it is then + # we know that there are no existing entires. - # Work out the new state for unsent rooms that were `LIVE`. if from_token: new_unsent_state = HaveSentRoom.previously(from_token.stream_token.room_key) - else: - new_unsent_state = HAVE_SENT_ROOM_NEVER - for room_id in unsent_room_ids: - prev_state = new_room_statuses.get(room_id) - if prev_state is not None and prev_state.status == HaveSentRoomFlag.LIVE: - new_room_statuses[room_id] = new_unsent_state - have_updated = True + for room_id in unsent_room_ids: + prev_state = new_room_statuses.get(room_id) + if ( + prev_state is not None + and prev_state.status == HaveSentRoomFlag.LIVE + ): + new_room_statuses[room_id] = new_unsent_state + have_updated = True if not have_updated: return prev_connection_token |