From 19b62d29ba54599913704e913b64e9e0baa7ef5f Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Thu, 8 Aug 2024 19:10:24 +0900 Subject: [PATCH] merged_tree: leverage .to_tree_merge() in TreeDiffIterator --- lib/src/merged_tree.rs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/lib/src/merged_tree.rs b/lib/src/merged_tree.rs index b9710726b..abb452077 100644 --- a/lib/src/merged_tree.rs +++ b/lib/src/merged_tree.rs @@ -622,25 +622,14 @@ impl<'matcher> TreeDiffIterator<'matcher> { } } - fn single_tree( - store: &Arc, - dir: &RepoPath, - value: Option<&TreeValue>, - ) -> BackendResult { - match value { - Some(TreeValue::Tree(tree_id)) => store.get_tree(dir, tree_id), - _ => Ok(Tree::null(store.clone(), dir.to_owned())), - } - } - /// Gets the given tree if `value` is a tree, otherwise an empty tree. fn trees( store: &Arc, dir: &RepoPath, values: &MergedTreeValue, ) -> BackendResult> { - if values.is_tree() { - values.try_map(|value| Self::single_tree(store, dir, value.as_ref())) + if let Some(trees) = values.to_tree_merge(store, dir)? { + Ok(trees) } else { Ok(Merge::resolved(Tree::null(store.clone(), dir.to_owned()))) }