mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-08 05:39:20 +00:00
merge: use Merge::iter() instead of adds()/removes() where order doesn't matter
Merge::iter() will be a slice::Iter, and be more efficient than chaining adds and removes.
This commit is contained in:
parent
99e6ff493a
commit
1c6913d618
1 changed files with 6 additions and 7 deletions
|
@ -84,12 +84,10 @@ impl MergedTree {
|
|||
/// Creates a new `MergedTree` representing a merge of a set of trees. The
|
||||
/// individual trees must not have any conflicts.
|
||||
pub fn new(trees: Merge<Tree>) -> Self {
|
||||
debug_assert!(!trees.removes().iter().any(|t| t.has_conflict()));
|
||||
debug_assert!(!trees.adds().iter().any(|t| t.has_conflict()));
|
||||
debug_assert!(itertools::chain(trees.removes(), trees.adds())
|
||||
.map(|tree| tree.dir())
|
||||
.all_equal());
|
||||
debug_assert!(itertools::chain(trees.removes(), trees.adds())
|
||||
debug_assert!(!trees.iter().any(|t| t.has_conflict()));
|
||||
debug_assert!(trees.iter().map(|tree| tree.dir()).all_equal());
|
||||
debug_assert!(trees
|
||||
.iter()
|
||||
.map(|tree| Arc::as_ptr(tree.store()))
|
||||
.all_equal());
|
||||
MergedTree::Merge(trees)
|
||||
|
@ -437,7 +435,8 @@ pub type TreeDiffStream<'matcher> = Pin<
|
|||
>;
|
||||
|
||||
fn all_tree_conflict_names(trees: &Merge<Tree>) -> impl Iterator<Item = &RepoPathComponent> {
|
||||
itertools::chain(trees.removes(), trees.adds())
|
||||
trees
|
||||
.iter()
|
||||
.map(|tree| tree.data().names())
|
||||
.kmerge()
|
||||
.dedup()
|
||||
|
|
Loading…
Reference in a new issue