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`.
This commit is contained in:
Ivan Enderlin
2026-01-23 15:49:48 +01:00
parent b0bc4b2af9
commit 9cf649eb60
+1 -1
View File
@@ -824,7 +824,7 @@ struct EventCacheInner {
multiple_room_updates_lock: Mutex<()>,
/// Lazily-filled cache of live [`RoomEventCache`], once per room.
by_room: RwLock<BTreeMap<OwnedRoomId, RoomEventCache>>,
by_room: RwLock<HashMap<OwnedRoomId, RoomEventCache>>,
/// Handles to keep alive the task listening to updates.
drop_handles: OnceLock<Arc<EventCacheDropHandles>>,