From b775bc7a9e846bea1136632b281ecc65c00b4c72 Mon Sep 17 00:00:00 2001 From: leeeon233 Date: Wed, 25 Sep 2024 09:39:52 +0800 Subject: [PATCH] fix: better tree cache current vv --- crates/loro-internal/src/diff_calc/tree.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/crates/loro-internal/src/diff_calc/tree.rs b/crates/loro-internal/src/diff_calc/tree.rs index e74b5ed6..09616ac3 100644 --- a/crates/loro-internal/src/diff_calc/tree.rs +++ b/crates/loro-internal/src/diff_calc/tree.rs @@ -232,6 +232,7 @@ impl TreeDiffCalculator { }; tree_cache.apply(op); } + tree_cache.current_vv = to.clone(); }); } @@ -324,7 +325,7 @@ impl TreeDiffCalculator { } } } - + tree_cache.current_vv = lca_vv; // forward tracing::info!("forward"); let group = h @@ -391,6 +392,7 @@ impl TreeDiffCalculator { } } } + tree_cache.current_vv = to.clone(); TreeDelta { diff: diffs } }) } @@ -476,14 +478,6 @@ impl TreeCacheForDiff { op.id.counter, op.id.counter + 1, )); - // Only shrink cannot get the correct empty vv, - if self.is_empty() { - self.current_vv = VersionVector::default(); - } - } - - fn is_empty(&self) -> bool { - self.tree.iter().all(|(_, v)| v.is_empty()) } fn is_ancestor_of(&self, maybe_ancestor: &TreeID, node_id: &TreeParentId) -> bool {