aboutsummaryrefslogtreecommitdiffstats
path: root/src/document/at.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-08 19:48:45 +0000
committertv <tv@krebsco.de>2026-11-08 20:49:06 +0100
commitb40d3f7ca3f92373eca8dd0683d37183559c78e6 (patch)
tree33431b749f234ed3bf1fdede1a4a5302464d0caf /src/document/at.rs
parent447ba15b16d71fe4c2285c4337aa99fe7b5d9df6 (diff)
document: tell whether a document holds a change without building it
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.
Diffstat (limited to 'src/document/at.rs')
-rw-r--r--src/document/at.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/document/at.rs b/src/document/at.rs
index d318f17..2d35736 100644
--- a/src/document/at.rs
+++ b/src/document/at.rs
@@ -23,7 +23,7 @@ impl<'a> At<'a> {
pub(crate) fn new(doc: &'a Document, heads: &[ChangeHash]) -> Option<Self> {
heads
.iter()
- .all(|head| doc.get_change_by_hash(head).is_some())
+ .all(|head| crate::document::changes::holds(doc, head))
.then(|| Self {
doc,
heads: heads.to_vec(),