summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-10-26 22:51:34 +0100
committerRichard van der Hoff <richard@matrix.org>2018-10-26 22:51:34 +0100
commit54bbe71867fb3de2e3984e2b3eb909845c2448b3 (patch)
tree115ee2fe4f2dcf504f17944a9b592eb6db9a8976
parentAddress review comments (diff)
downloadsynapse-54bbe71867fb3de2e3984e2b3eb909845c2448b3.tar.xz
optimise state copying
-rw-r--r--synapse/handlers/room.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index 145b5b19ee..8e48c1ca6a 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -21,7 +21,7 @@ import math
 import string
 from collections import OrderedDict
 
-from six import string_types
+from six import iteritems, string_types
 
 from twisted.internet import defer
 
@@ -237,12 +237,10 @@ class RoomCreationHandler(BaseHandler):
         # map from event_id to BaseEvent
         old_room_state_events = yield self.store.get_events(old_room_state_ids.values())
 
-        for k in types_to_copy:
-            old_event_id = old_room_state_ids.get(k)
-            if old_event_id:
-                old_event = old_room_state_events.get(old_event_id)
-                if old_event:
-                    initial_state[k] = old_event.content
+        for k, old_event_id in iteritems(old_room_state_ids):
+            old_event = old_room_state_events.get(old_event_id)
+            if old_event:
+                initial_state[k] = old_event.content
 
         yield self._send_events_for_new_room(
             requester,