From 9cf649eb6003ebc9c6677cf925ac509b05fe6ec6 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Fri, 23 Jan 2026 15:49:48 +0100 Subject: [PATCH] fix(sdk): `EventCacheInner::by_room` can be a `HashMap`. This patch replaces `HashMap` by `BTreeMap` in `EventCacheInner` as we don't need any ordering. It is then faster to get (or insert) a new `RoomEventCache`: - an insert is O(1) for `HashMap` vs. O(log(n)) for `BTreeMap`, - a get is O(1) for `HashMap` vs. O(log(n)) for `BTreeMap`. --- crates/matrix-sdk/src/event_cache/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/matrix-sdk/src/event_cache/mod.rs b/crates/matrix-sdk/src/event_cache/mod.rs index fd6d91b6c..b1f4be510 100644 --- a/crates/matrix-sdk/src/event_cache/mod.rs +++ b/crates/matrix-sdk/src/event_cache/mod.rs @@ -824,7 +824,7 @@ struct EventCacheInner { multiple_room_updates_lock: Mutex<()>, /// Lazily-filled cache of live [`RoomEventCache`], once per room. - by_room: RwLock>, + by_room: RwLock>, /// Handles to keep alive the task listening to updates. drop_handles: OnceLock>,