summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-02-22 13:54:46 +0000
committerErik Johnston <erik@matrix.org>2016-02-22 13:54:46 +0000
commit9e696bd6a38f280e40f7ec47f457bd1052f1723d (patch)
tree977fefd8ceee7c3ca74d0701369fe25acb336e17
parentMerge pull request #589 from matrix-org/erikj/presence (diff)
downloadsynapse-9e696bd6a38f280e40f7ec47f457bd1052f1723d.tar.xz
Remove superfluous call to get_state_at when we already have an event for that stream position
Diffstat (limited to '')
-rw-r--r--synapse/handlers/sync.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py
index efeec72fd8..558c7bacb9 100644
--- a/synapse/handlers/sync.py
+++ b/synapse/handlers/sync.py
@@ -845,16 +845,20 @@ class SyncHandler(BaseHandler):
         # TODO(mjark) Check for new redactions in the state events.
 
         with Measure(self.clock, "compute_state_delta"):
-            current_state = yield self.get_state_at(
-                room_id, stream_position=now_token
-            )
-
             if full_state:
                 if batch:
+                    current_state = yield self.store.get_state_for_event(
+                        batch.events[-1].event_id
+                    )
+
                     state = yield self.store.get_state_for_event(
                         batch.events[0].event_id
                     )
                 else:
+                    current_state = yield self.get_state_at(
+                        room_id, stream_position=now_token
+                    )
+
                     state = current_state
 
                 timeline_state = {
@@ -873,6 +877,10 @@ class SyncHandler(BaseHandler):
                     room_id, stream_position=since_token
                 )
 
+                current_state = yield self.store.get_state_for_event(
+                    batch.events[-1].event_id
+                )
+
                 state_at_timeline_start = yield self.store.get_state_for_event(
                     batch.events[0].event_id
                 )