mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-19 06:04:26 +00:00
merge: optimize 3-way merge case
I haven't done any profiling to see if this is actually useful, but it's also pretty simple to do.
This commit is contained in:
parent
aa2792c5e5
commit
ef7b831411
@ -29,6 +29,19 @@ where
|
|||||||
"trivial_merge() requires exactly one more adds than removes"
|
"trivial_merge() requires exactly one more adds than removes"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Optimize the common case of a 3-way merge
|
||||||
|
if adds.len() == 2 {
|
||||||
|
return if adds[0] == adds[1] {
|
||||||
|
Some(adds[0].clone())
|
||||||
|
} else if adds[0] == removes[0] {
|
||||||
|
Some(adds[1].clone())
|
||||||
|
} else if adds[1] == removes[0] {
|
||||||
|
Some(adds[0].clone())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Check if all sides made the same change.
|
// Check if all sides made the same change.
|
||||||
// This matches what Git and Mercurial do (in the 3-way case at least), but not
|
// This matches what Git and Mercurial do (in the 3-way case at least), but not
|
||||||
// what Darcs and Pijul do. It means that repeated 3-way merging of multiple
|
// what Darcs and Pijul do. It means that repeated 3-way merging of multiple
|
||||||
|
Loading…
x
Reference in New Issue
Block a user