summary refs log tree commit diff
path: root/synapse/storage/devices.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-03-23 17:53:49 +0000
committerErik Johnston <erik@matrix.org>2017-03-23 17:53:49 +0000
commit00957d1aa4b01a199ab2c3abf30032a0ca0b1e12 (patch)
tree79f6e968f784c6d4e05cda9c298d5a32fbc88291 /synapse/storage/devices.py
parentMerge pull request #2005 from kfatehi/docs/readme (diff)
downloadsynapse-00957d1aa4b01a199ab2c3abf30032a0ca0b1e12.tar.xz
User Cursor.__iter__ instead of fetchall
This prevents unnecessary construction of lists
Diffstat (limited to 'synapse/storage/devices.py')
-rw-r--r--synapse/storage/devices.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/synapse/storage/devices.py b/synapse/storage/devices.py
index e545b62e39..6beeff8b00 100644
--- a/synapse/storage/devices.py
+++ b/synapse/storage/devices.py
@@ -333,13 +333,12 @@ class DeviceStore(SQLBaseStore):
         txn.execute(
             sql, (destination, from_stream_id, now_stream_id, False)
         )
-        rows = txn.fetchall()
 
-        if not rows:
+        # maps (user_id, device_id) -> stream_id
+        query_map = {(r[0], r[1]): r[2] for r in txn}
+        if not query_map:
             return (now_stream_id, [])
 
-        # maps (user_id, device_id) -> stream_id
-        query_map = {(r[0], r[1]): r[2] for r in rows}
         devices = self._get_e2e_device_keys_txn(
             txn, query_map.keys(), include_all_devices=True
         )