From 2aa2fb8c757c9595084960804a128ea701b17356 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 7 Nov 2026 22:35:21 +0100 Subject: bench: change paths Finding the paths changes touch, from documents and from raw change bytes, measured before M6 is built. Auth plan M6 (measure first). --- src/document/store.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/document/store.rs') diff --git a/src/document/store.rs b/src/document/store.rs index 2e27b44..31c4824 100644 --- a/src/document/store.rs +++ b/src/document/store.rs @@ -93,8 +93,19 @@ pub(crate) fn changed_by( hash: &automerge::ChangeHash, lists: InLists, ) -> Option>> { - use automerge::legacy::{Key, ObjectId}; let change = doc.get_change_by_hash(hash)?.decode(); + Some(changed_by_decoded(doc, hash, change, lists)) +} + +/// [`changed_by`] of a change already decoded (`change`, whose hash is `hash`), as from +/// the bytes it came as: what the document rebuilding it would cost spared. +pub(crate) fn changed_by_decoded( + doc: &Automerge, + hash: &automerge::ChangeHash, + change: automerge::ExpandedChange, + lists: InLists, +) -> Vec> { + use automerge::legacy::{Key, ObjectId}; let heads = [*hash]; // Each object's path as it was after the change, and whether that is a list's (as // `InLists::Whole` names what is inside one). @@ -127,7 +138,7 @@ pub(crate) fn changed_by( } paths.insert(path); } - Some(paths.into_iter().collect()) + paths.into_iter().collect() } /// Whether one path is within the other (a change at either touches both). -- cgit v1.3.1