Skip to content

Commit 9ccf94d

Browse files
authored
Merge pull request #3552 from Hywan/fix-base-store-get-rooms-fast
feat(base): Make `Store::get_rooms` wayyy faster
2 parents 5178cbb + 15ab776 commit 9ccf94d

File tree

1 file changed

+2
-1
lines changed
  • crates/matrix-sdk-base/src/store

1 file changed

+2
-1
lines changed

crates/matrix-sdk-base/src/store/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ pub(crate) struct Store {
142142
session_meta: Arc<OnceCell<SessionMeta>>,
143143
/// The current sync token that should be used for the next sync call.
144144
pub(super) sync_token: Arc<RwLock<Option<String>>>,
145+
/// All rooms the store knows about.
145146
rooms: Arc<StdRwLock<BTreeMap<OwnedRoomId, Room>>>,
146147
/// A lock to synchronize access to the store, such that data by the sync is
147148
/// never overwritten.
@@ -203,7 +204,7 @@ impl Store {
203204

204205
/// Get all the rooms this store knows about.
205206
pub fn get_rooms(&self) -> Vec<Room> {
206-
self.rooms.read().unwrap().keys().filter_map(|id| self.get_room(id)).collect()
207+
self.rooms.read().unwrap().values().cloned().collect()
207208
}
208209

209210
/// Get all the rooms this store knows about, filtered by state.

0 commit comments

Comments
 (0)