summary refs log tree commit diff
path: root/synapse/storage/databases/state
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2023-10-26 13:01:36 -0400
committerGitHub <noreply@github.com>2023-10-26 13:01:36 -0400
commit9407d5ba78d1e5275b5817ae9e6aedf7d1ca14f7 (patch)
tree70935c19b787e89115d6f8884f3d134a6bacf264 /synapse/storage/databases/state
parentPin the recommended poetry version in contributors' guide (#16550) (diff)
downloadsynapse-9407d5ba78d1e5275b5817ae9e6aedf7d1ca14f7.tar.xz
Convert simple_select_list and simple_select_list_txn to return lists of tuples (#16505)
This should use fewer allocations and improves type hints.
Diffstat (limited to 'synapse/storage/databases/state')
-rw-r--r--synapse/storage/databases/state/store.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/synapse/storage/databases/state/store.py b/synapse/storage/databases/state/store.py
index 09d2a8c5b3..182e429174 100644
--- a/synapse/storage/databases/state/store.py
+++ b/synapse/storage/databases/state/store.py
@@ -154,16 +154,22 @@ class StateGroupDataStore(StateBackgroundUpdateStore, SQLBaseStore):
             if not prev_group:
                 return _GetStateGroupDelta(None, None)
 
-            delta_ids = self.db_pool.simple_select_list_txn(
-                txn,
-                table="state_groups_state",
-                keyvalues={"state_group": state_group},
-                retcols=("type", "state_key", "event_id"),
+            delta_ids = cast(
+                List[Tuple[str, str, str]],
+                self.db_pool.simple_select_list_txn(
+                    txn,
+                    table="state_groups_state",
+                    keyvalues={"state_group": state_group},
+                    retcols=("type", "state_key", "event_id"),
+                ),
             )
 
             return _GetStateGroupDelta(
                 prev_group,
-                {(row["type"], row["state_key"]): row["event_id"] for row in delta_ids},
+                {
+                    (event_type, state_key): event_id
+                    for event_type, state_key, event_id in delta_ids
+                },
             )
 
         return await self.db_pool.runInteraction(