mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-01 00:50:57 +00:00
merged_tree: keep Arc<Store> globally in TreeDiffStreamImpl
I'll replace treeN: MergedTree with Merge<Tree>, and it's simpler to just keep the store by TreeDiffStreamImpl.
This commit is contained in:
parent
a3ca6c6f46
commit
991b0e8b68
1 changed files with 5 additions and 2 deletions
|
@ -849,6 +849,7 @@ impl Iterator for TreeDiffIterator<'_> {
|
||||||
|
|
||||||
/// Stream of differences between two trees.
|
/// Stream of differences between two trees.
|
||||||
pub struct TreeDiffStreamImpl<'matcher> {
|
pub struct TreeDiffStreamImpl<'matcher> {
|
||||||
|
store: Arc<Store>,
|
||||||
matcher: &'matcher dyn Matcher,
|
matcher: &'matcher dyn Matcher,
|
||||||
/// Pairs of tree values that may or may not be ready to emit, sorted in the
|
/// Pairs of tree values that may or may not be ready to emit, sorted in the
|
||||||
/// order we want to emit them. If either side is a tree, there will be
|
/// order we want to emit them. If either side is a tree, there will be
|
||||||
|
@ -926,7 +927,9 @@ impl<'matcher> TreeDiffStreamImpl<'matcher> {
|
||||||
matcher: &'matcher dyn Matcher,
|
matcher: &'matcher dyn Matcher,
|
||||||
max_concurrent_reads: usize,
|
max_concurrent_reads: usize,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
assert!(Arc::ptr_eq(tree1.store(), tree2.store()));
|
||||||
let mut stream = Self {
|
let mut stream = Self {
|
||||||
|
store: tree1.store().clone(),
|
||||||
matcher,
|
matcher,
|
||||||
items: BTreeMap::new(),
|
items: BTreeMap::new(),
|
||||||
pending_trees: VecDeque::new(),
|
pending_trees: VecDeque::new(),
|
||||||
|
@ -1007,9 +1010,9 @@ impl<'matcher> TreeDiffStreamImpl<'matcher> {
|
||||||
// If the path was a tree on either side of the diff, read those trees.
|
// If the path was a tree on either side of the diff, read those trees.
|
||||||
if tree_matches {
|
if tree_matches {
|
||||||
let before_tree_future =
|
let before_tree_future =
|
||||||
Self::tree(tree1.store().clone(), path.clone(), before.cloned());
|
Self::tree(self.store.clone(), path.clone(), before.cloned());
|
||||||
let after_tree_future =
|
let after_tree_future =
|
||||||
Self::tree(tree2.store().clone(), path.clone(), after.cloned());
|
Self::tree(self.store.clone(), path.clone(), after.cloned());
|
||||||
let both_trees_future =
|
let both_trees_future =
|
||||||
async { futures::try_join!(before_tree_future, after_tree_future) };
|
async { futures::try_join!(before_tree_future, after_tree_future) };
|
||||||
self.pending_trees
|
self.pending_trees
|
||||||
|
|
Loading…
Reference in a new issue