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

doc(common): Update documentation of AsVector #4435

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions crates/matrix-sdk-common/src/linked_chunk/as_vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,19 @@ impl UpdateToVectorDiff {
/// [`VectorDiff`] is emitted,
/// * [`Update::StartReattachItems`] and [`Update::EndReattachItems`] are
/// respectively muting or unmuting the emission of [`VectorDiff`] by
/// [`Update::PushItems`].
/// [`Update::PushItems`],
/// * [`Update::Clear`] reinitialises the state.
///
/// The only `VectorDiff` that are emitted are [`VectorDiff::Insert`] or
/// [`VectorDiff::Append`] because a [`LinkedChunk`] is append-only.
/// The only `VectorDiff` that are emitted are [`VectorDiff::Insert`],
/// [`VectorDiff::Append`], [`VectorDiff::Remove`] and
/// [`VectorDiff::Clear`].
///
/// `VectorDiff::Append` is an optimisation when numerous
/// `VectorDiff::Insert`s have to be emitted at the last position.
///
/// `VectorDiff::Insert` need an index. To compute this index, the algorithm
/// will iterate over all pairs to accumulate each chunk length until it
/// finds the appropriate pair (given by
/// `VectorDiff::Insert` needs an index. To compute this index, the
/// algorithm will iterate over all pairs to accumulate each chunk length
/// until it finds the appropriate pair (given by
/// [`Update::PushItems::at`]). This is _the offset_. To this offset, the
/// algorithm adds the position's index of the new items (still given by
/// [`Update::PushItems::at`]). This is _the index_. This logic works
Expand Down
Loading