feat(sdk): SlidingSync::get_room now takes a ref to OwnedRoomId.

Before this patch, `SlidingSync::get_room` was taking ownership of an
`OwnedRoomId`, to only use it as a reference. Thus, calling this method was
creating useless clones.

This patch updates `SlidingSync::get_room` to receive a reference to
`OwnedRoomId`.
This commit is contained in:
Ivan Enderlin
2023-02-02 13:25:36 +01:00
parent 5dbee7dcdc
commit a9ba2dd546
2 changed files with 4 additions and 3 deletions

View File

@@ -642,7 +642,8 @@ impl SlidingSync {
pub fn get_room(&self, room_id: String) -> anyhow::Result<Option<Arc<SlidingSyncRoom>>> {
let runner = self.inner.clone();
Ok(self.inner.get_room(OwnedRoomId::try_from(room_id)?).map(|inner| {
Ok(self.inner.get_room(&OwnedRoomId::try_from(room_id)?).map(|inner| {
Arc::new(SlidingSyncRoom {
inner,
runner,

View File

@@ -814,8 +814,8 @@ impl SlidingSync {
}
/// Lookup a specific room
pub fn get_room(&self, room_id: OwnedRoomId) -> Option<SlidingSyncRoom> {
self.rooms.lock_ref().get(&room_id).cloned()
pub fn get_room(&self, room_id: &OwnedRoomId) -> Option<SlidingSyncRoom> {
self.rooms.lock_ref().get(room_id).cloned()
}
fn update_to_device_since(&self, since: String) {