Skip to content

Commit

Permalink
crypto: Improve memory overhead of export_room_keys by using Vec::retain
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Balaam <[email protected]>
  • Loading branch information
andybalaam committed Jan 12, 2024
1 parent 3fea9ae commit 985f9f9
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions crates/matrix-sdk-crypto/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 985f9f9

Please sign in to comment.