Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ui): Use an iterator instead of Vec to represent events #4361

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

Hywan
Copy link
Member

@Hywan Hywan commented Dec 2, 2024

(Extracted from #3512)

This patch changes TimelineStateTransaction::add_remote_events_at to take an IntoIterator<Item = Into<SyncTimelineEvent>> for events. In the current code, it saves one
iter().map(Into::into).collect::<Vec<_>>(), but it will save another one when we will support VectorDiffs coming from the EventCache.

It also avoids to allocate a vector to pass new events (this mostly happens in the tests, but it can happen in real life).


This patch changes `TimelineStateTransaction::add_remote_events_at`
to take an `IntoIterator<Item = Into<SyncTimelineEvent>>`
for `events`. In the current code, it saves one
`iter().map(Into::into).collect::<Vec<_>>()`, but it will save another
one when we will support `VectorDiff`s coming from the `EventCache`.

It also avoids to allocate a vector to pass new events (this mostly
happens in the test, but it can happen in real life).
Copy link

codecov bot commented Dec 2, 2024

Codecov Report

Attention: Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.

Project coverage is 85.14%. Comparing base (685386d) to head (3aed186).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
crates/matrix-sdk-ui/src/timeline/builder.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4361      +/-   ##
==========================================
+ Coverage   85.10%   85.14%   +0.03%     
==========================================
  Files         280      280              
  Lines       30535    30539       +4     
==========================================
+ Hits        25988    26001      +13     
+ Misses       4547     4538       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Hywan Hywan marked this pull request as ready for review December 2, 2024 11:09
@Hywan Hywan requested a review from a team as a code owner December 2, 2024 11:09
@Hywan Hywan requested review from poljar and bnjbvr and removed request for a team and poljar December 2, 2024 11:09
Copy link
Member

@bnjbvr bnjbvr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

@Hywan Hywan enabled auto-merge (rebase) December 2, 2024 11:35
@Hywan Hywan merged commit ad3d1fb into matrix-org:main Dec 2, 2024
76 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants