crypto: Improve memory overhead of export_room_keys by using Vec::retain

Signed-off-by: Andy Balaam <andy.balaam@matrix.org>
This commit is contained in:
Andy Balaam
2024-01-12 14:44:21 +00:00
parent 3fea9ae51a
commit 985f9f9b07

View File

@@ -1830,13 +1830,9 @@ impl OlmMachine {
) -> StoreResult<Vec<ExportedRoomKey>> {
let mut exported = Vec::new();
let sessions: Vec<InboundGroupSession> = self
.store()
.get_inbound_group_sessions()
.await?
.into_iter()
.filter(|s| predicate(s))
.collect();
let mut sessions = self.store().get_inbound_group_sessions().await?;
sessions.retain(|s| predicate(s));
for session in sessions {
let export = session.export().await;