Skip to content

Commit 4603ee1

Browse files
committed
Remove unnecessary string copies
1 parent da657b8 commit 4603ee1

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

crates/matrix-sdk-crypto/src/machine.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -714,10 +714,10 @@ impl OlmMachine {
714714
room_id: &RoomId,
715715
content: impl MessageEventContent,
716716
) -> MegolmResult<RoomEncryptedEventContent> {
717-
let event_type = content.event_type().to_owned();
718-
let content = serde_json::to_value(content)?;
717+
let event_type = content.event_type();
718+
let content = serde_json::to_value(&content)?;
719719

720-
self.group_session_manager.encrypt(room_id, content, &event_type).await
720+
self.group_session_manager.encrypt(room_id, content, event_type).await
721721
}
722722

723723
/// Encrypt a json [`Value`] content for the given room.

crates/matrix-sdk/src/room/joined.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,10 @@ impl Joined {
465465
content: impl MessageEventContent,
466466
txn_id: Option<Uuid>,
467467
) -> Result<send_message_event::Response> {
468-
let event_type = content.event_type().to_owned();
469-
let content = serde_json::to_value(content)?;
468+
let event_type = content.event_type();
469+
let content = serde_json::to_value(&content)?;
470470

471-
self.send_raw(content, &event_type, txn_id).await
471+
self.send_raw(content, event_type, txn_id).await
472472
}
473473

474474
/// Send a room message to this room from a json `Value`.

0 commit comments

Comments
 (0)