Skip to content

Commit e62e606

Browse files
committed
chore(sdk): Simplify code in listen_to_event_cache_and_send_queue_updates_task.
This patch removes the intermediate `rooms` variable in a new block. The read-lock can be used immediately.
1 parent 1089a25 commit e62e606

File tree

1 file changed

+5
-8
lines changed
  • crates/matrix-sdk/src/latest_events

1 file changed

+5
-8
lines changed

crates/matrix-sdk/src/latest_events/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -537,14 +537,11 @@ async fn listen_to_event_cache_and_send_queue_updates_task(
537537

538538
// Initialise the list of rooms that are listened.
539539
//
540-
// Technically, we can use `rooms` to get this information, but it would involve
541-
// a read-lock. In order to reduce the pressure on this lock, we use
542-
// this intermediate structure.
543-
let mut listened_rooms = {
544-
let rooms = registered_rooms.rooms.read().await;
545-
546-
HashSet::from_iter(rooms.keys().cloned())
547-
};
540+
// Technically, we can use `registered_rooms.rooms` every time to get this
541+
// information, but it would involve a read-lock. In order to reduce the
542+
// pressure on this lock, we use this intermediate structure.
543+
let mut listened_rooms =
544+
HashSet::from_iter(registered_rooms.rooms.read().await.keys().cloned());
548545

549546
loop {
550547
if listen_to_event_cache_and_send_queue_updates(

0 commit comments

Comments
 (0)