From 8b805b1ea54a6f90a9ae8a65ce4bac0b464bfb13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Tue, 4 Nov 2025 12:18:03 +0100 Subject: [PATCH] refactor: Try to avoid filtering all event items before finding one with the wanted id --- .../src/timeline/controller/read_receipts.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/matrix-sdk-ui/src/timeline/controller/read_receipts.rs b/crates/matrix-sdk-ui/src/timeline/controller/read_receipts.rs index 2de2e9eaf..2dc9330b4 100644 --- a/crates/matrix-sdk-ui/src/timeline/controller/read_receipts.rs +++ b/crates/matrix-sdk-ui/src/timeline/controller/read_receipts.rs @@ -449,9 +449,12 @@ impl ReadReceiptTimelineUpdate { // Don't iterate over all items if the `old_item_pos` is known: the `item_pos` // for the new item is necessarily _after_ the old item. .skip_while(|(nth, _)| *nth < old_item_pos) - .filter_map(|(nth, item)| Some((nth, item.as_event()?))) - .find_map(|(nth, event_item)| { - (event_item.event_id() == Some(&event_id)).then_some(nth) + .find_map(|(nth, item)| { + if let Some(event_item) = item.as_event() { + (event_item.event_id() == Some(&event_id)).then_some(nth) + } else { + None + } }) });