From b0fa52f17f0edd83df1785d4134320ea0e77cb9b Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Fri, 29 May 2026 13:46:06 +0200 Subject: [PATCH] refactor(common): `TimelineEvent::event_id` now returns an `Option<&EventId>`. This patch updates `TimelineEvent::event_id` to return an `Option<&EventId>` instead of an `Option`. It avoids cloning the event ID. --- .../matrix-sdk-common/src/deserialized_responses.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/matrix-sdk-common/src/deserialized_responses.rs b/crates/matrix-sdk-common/src/deserialized_responses.rs index 0e5115b26..35e7da293 100644 --- a/crates/matrix-sdk-common/src/deserialized_responses.rs +++ b/crates/matrix-sdk-common/src/deserialized_responses.rs @@ -15,7 +15,8 @@ use std::{collections::BTreeMap, fmt, ops::Not, sync::Arc}; use ruma::{ - DeviceKeyAlgorithm, MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedEventId, OwnedUserId, + DeviceKeyAlgorithm, EventId, MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedEventId, + OwnedUserId, events::{ AnySyncMessageLikeEvent, AnySyncTimelineEvent, AnyTimelineEvent, AnyToDeviceEvent, MessageLikeEventType, room::encrypted::EncryptedEventScheme, @@ -801,10 +802,10 @@ impl TimelineEvent { self.push_actions = Some(push_actions); } - /// Get the (cached) event ID of this [`TimelineEvent`] if the event has any - /// valid ID. - pub fn event_id(&self) -> Option { - self.event_id.clone() + /// Get the (cached) event ID of this [`TimelineEvent`] if the event has + /// any valid ID. + pub fn event_id(&self) -> Option<&EventId> { + self.event_id.as_deref() } /// Get the sender of this [`TimelineEvent`] if the event has one.