mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-02 18:01:05 +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
1 changed files with 13 additions and 0 deletions
|
@ -29,6 +29,19 @@ where
|
|||
"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.
|
||||
// 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
|
||||
|
|
Loading…
Reference in a new issue