From 6a73f5d9e9a18346fc2473f660619db73bf30a89 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 13 Jun 2024 16:28:38 +0200 Subject: [PATCH] feat(base): Faster `Store::rooms_filtered`. Just like in https://github.com/matrix-org/matrix-rust-sdk/pull/3552, this patch updates `Store::rooms_filtered` to not call `Store::room` so that it doesn't lock `rooms` for each item, thus making it way faster. --- crates/matrix-sdk-base/src/store/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/matrix-sdk-base/src/store/mod.rs b/crates/matrix-sdk-base/src/store/mod.rs index a8c2f858a5c..63ca7ee90dc 100644 --- a/crates/matrix-sdk-base/src/store/mod.rs +++ b/crates/matrix-sdk-base/src/store/mod.rs @@ -213,8 +213,7 @@ impl Store { .read() .unwrap() .iter() - .filter(|(_, r)| filter.matches(r.state())) - .filter_map(|(id, _)| self.get_room(id)) + .filter_map(|(_, room)| filter.matches(room.state()).then(|| room.clone())) .collect() }