diff --git a/crates/matrix-sdk/src/sliding_sync/mod.rs b/crates/matrix-sdk/src/sliding_sync/mod.rs index df2c83612..73fab5830 100644 --- a/crates/matrix-sdk/src/sliding_sync/mod.rs +++ b/crates/matrix-sdk/src/sliding_sync/mod.rs @@ -354,9 +354,11 @@ impl SlidingSync { } let update_summary = { - let mut updated_rooms = Vec::new(); let mut rooms_map = self.inner.rooms.write().unwrap(); + // Update the rooms. + let mut updated_rooms = Vec::with_capacity(sliding_sync_response.rooms.len()); + for (room_id, mut room_data) in sliding_sync_response.rooms.into_iter() { // `sync_response` contains the rooms with decrypted events if any, so look at // the timeline events here first if the room exists. @@ -390,7 +392,8 @@ impl SlidingSync { updated_rooms.push(room_id); } - let mut updated_lists = Vec::new(); + // Update the lists. + let mut updated_lists = Vec::with_capacity(sliding_sync_response.lists.len()); for (name, updates) in sliding_sync_response.lists { let Some(list) = lists.get_mut(&name) else {