Skip to content

Commit e7f2c19

Browse files
committed
refactor(event cache): apply review comments of #4708
1 parent 475ad79 commit e7f2c19

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

crates/matrix-sdk-base/src/event_cache/store/integration_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ impl EventCacheStoreIntegrationTests for DynEventCacheStore {
846846
.await
847847
.unwrap();
848848

849-
// Now let's find out the event.
849+
// Now let's find the event.
850850
let (position, event) = self
851851
.find_event(room_id, event_comte.event_id().unwrap().as_ref())
852852
.await

crates/matrix-sdk-base/src/event_cache/store/memory_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl EventCacheStore for MemoryStore {
183183

184184
let mut duplicated_events = Vec::new();
185185

186-
for (event, position) in inner.events.unordered_items(room_id) {
186+
for (event, position) in inner.events.unordered_room_items(room_id) {
187187
// If `events` is empty, we can short-circuit.
188188
if events.is_empty() {
189189
break;

crates/matrix-sdk-common/src/linked_chunk/relational.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ impl<Item, Gap> RelationalLinkedChunk<Item, Gap> {
293293
}
294294
}
295295

296-
/// Return an iterator that yields items of a particular room with no
296+
/// Return an iterator that yields items of a particular room, in no
297297
/// particular order.
298-
pub fn unordered_items<'a>(
298+
pub fn unordered_room_items<'a>(
299299
&'a self,
300300
room_id: &'a RoomId,
301301
) -> impl Iterator<Item = (&'a Item, Position)> {
@@ -311,7 +311,7 @@ impl<Item, Gap> RelationalLinkedChunk<Item, Gap> {
311311
})
312312
}
313313

314-
/// Return an iterator over all items.
314+
/// Return an iterator over all items of all rooms, in no particular order.
315315
pub fn items(&self) -> impl Iterator<Item = (Position, &Item, &RoomId)> {
316316
self.items.iter().filter_map(|item_row| {
317317
if let Either::Item(item) = &item_row.item {
@@ -1142,7 +1142,7 @@ mod tests {
11421142
],
11431143
);
11441144

1145-
let mut events = relational_linked_chunk.unordered_items(room_id);
1145+
let mut events = relational_linked_chunk.unordered_room_items(room_id);
11461146

11471147
assert_eq!(events.next().unwrap(), (&'a', Position::new(CId::new(0), 0)));
11481148
assert_eq!(events.next().unwrap(), (&'b', Position::new(CId::new(0), 1)));

crates/matrix-sdk/src/event_cache/room/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,10 @@ impl RoomEventCache {
190190
return None;
191191
};
192192

193+
// Search in `AllEventsCache` for known events that are not stored.
193194
if let Some(event) = maybe_position_and_event.map(|(_position, event)| event) {
194195
Some(event)
195-
}
196-
// Search in `AllEventsCache` for known events that are not stored.
197-
else if let Some((room_id, event)) =
196+
} else if let Some((room_id, event)) =
198197
self.inner.all_events.read().await.events.get(event_id).cloned()
199198
{
200199
(room_id == self.inner.room_id).then_some(event)

0 commit comments

Comments
 (0)