From b40d3f7ca3f92373eca8dd0683d37183559c78e6 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 8 Nov 2026 19:48:45 +0000 Subject: document: tell whether a document holds a change without building it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the policy's reads kept, judging a change still costs about one read (some 3.5 µs), and so does judging without a policy: what is left is At::new, which asks get_change_by_hash for each head. Automerge builds the change again from the document's operations to answer, at a cost growing with its history. Screening asks it again for every candidate and every dependency, and sync for heads. Ask by the missing dependencies instead (changes::holds), which look the hash up: one the document holds is not among them. A change queued in the document, waiting for its dependencies, isn't either; but then some are missing, and only then is it asked the slow way. Every check of whether a document holds a change goes through it. --- src/remake/snapshot.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/remake') diff --git a/src/remake/snapshot.rs b/src/remake/snapshot.rs index ee0a2cd..dc61810 100644 --- a/src/remake/snapshot.rs +++ b/src/remake/snapshot.rs @@ -274,7 +274,7 @@ pub(crate) fn build( ) -> Result { // fork_at with unknown heads would quietly build something else. for head in params.base_heads { - if source.get_change_by_hash(head).is_none() { + if !crate::document::changes::holds(source, head) { return Err(SnapshotError::MissingBase(*head)); } } -- cgit v1.3.1