diff --git a/crates/matrix-sdk/src/event_cache/room/events.rs b/crates/matrix-sdk/src/event_cache/room/events.rs index 516432304a6..230d24fd47e 100644 --- a/crates/matrix-sdk/src/event_cache/room/events.rs +++ b/crates/matrix-sdk/src/event_cache/room/events.rs @@ -102,7 +102,7 @@ impl RoomEvents { let (events, duplicated_event_ids) = self.collect_valid_and_duplicated_events(events.into_iter()); - if deduplicated_all_new_events(events.len(), duplicated_event_ids.len()) { + if has_zero_new_unique_events(events.len(), duplicated_event_ids.len()) { return false; } @@ -133,7 +133,7 @@ impl RoomEvents { let (events, duplicated_event_ids) = self.collect_valid_and_duplicated_events(events.into_iter()); - if deduplicated_all_new_events(events.len(), duplicated_event_ids.len()) { + if has_zero_new_unique_events(events.len(), duplicated_event_ids.len()) { return Ok(false); } @@ -174,7 +174,7 @@ impl RoomEvents { let (events, duplicated_event_ids) = self.collect_valid_and_duplicated_events(events.into_iter()); - if deduplicated_all_new_events(events.len(), duplicated_event_ids.len()) { + if has_zero_new_unique_events(events.len(), duplicated_event_ids.len()) { let pos = self.chunks.remove_gap_at(gap_identifier)?; return Ok((false, pos)); } @@ -326,8 +326,12 @@ impl RoomEvents { /// already seen, and possibly misplace them. And we should not be missing /// events either: the already-known events would have their own previous-batch /// token (it might already be consumed). -fn deduplicated_all_new_events(num_new_unique: usize, num_duplicated: usize) -> bool { - num_new_unique > 0 && num_new_unique == num_duplicated +#[inline] +fn has_zero_new_unique_events( + number_of_new_events: usize, + number_of_duplicated_events: usize, +) -> bool { + number_of_new_events > 0 && number_of_new_events == number_of_duplicated_events } // Private implementations, implementation specific.