Skip to content

Commit

Permalink
Merge pull request #3013 from matrix-org/andybalaam/retain-in-export_…
Browse files Browse the repository at this point in the history
…room_keys

crypto: Improve memory overhead of export_room_keys by using Vec::retain
  • Loading branch information
andybalaam authored Jan 15, 2024
2 parents c411306 + 7034104 commit 58be7b0
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions crates/matrix-sdk-crypto/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1826,17 +1826,12 @@ impl OlmMachine {
/// ```
pub async fn export_room_keys(
&self,
mut predicate: impl FnMut(&InboundGroupSession) -> bool,
predicate: impl FnMut(&InboundGroupSession) -> bool,
) -> 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(predicate);

for session in sessions {
let export = session.export().await;
Expand Down

0 comments on commit 58be7b0

Please sign in to comment.