summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-07-24 10:55:11 +0100
committerErik Johnston <erik@matrix.org>2018-07-24 10:55:11 +0100
commitff5426f6b8263b416f412725a6d7be2fac284824 (patch)
treeff0285999f74c05e56220b1c8679681882b437d0 /synapse/storage
parentMerge pull request #3584 from matrix-org/erikj/use_cached (diff)
downloadsynapse-ff5426f6b8263b416f412725a6d7be2fac284824.tar.xz
Speed up _calculate_state_delta
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/events.py13
1 files changed, 3 insertions, 10 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index c2910094d0..1b075e6cc6 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -644,21 +644,14 @@ class EventsStore(EventsWorkerStore):
         """
         existing_state = yield self.get_current_state_ids(room_id)
 
-        existing_events = set(itervalues(existing_state))
-        new_events = set(ev_id for ev_id in itervalues(current_state))
-        changed_events = existing_events ^ new_events
-
-        if not changed_events:
-            return
-
         to_delete = {
             key: ev_id for key, ev_id in iteritems(existing_state)
-            if ev_id in changed_events
+            if ev_id != current_state.get(key)
         }
-        events_to_insert = (new_events - existing_events)
+
         to_insert = {
             key: ev_id for key, ev_id in iteritems(current_state)
-            if ev_id in events_to_insert
+            if ev_id != existing_state.get(key)
         }
 
         defer.returnValue((to_delete, to_insert))