merge: fast-path trivial merge of 1-way "conflicts"

I don't think we call `trivial_merge()` for 1-way "conflicts" yet, but
I'll probably end up doing that soon.
This commit is contained in:
Martin von Zweigbergk 2023-06-22 01:53:57 -07:00 committed by Martin von Zweigbergk
parent 9c486ebe45
commit b8f6a48c66

View file

@ -29,8 +29,10 @@ where
"trivial_merge() requires exactly one more adds than removes"
);
// Optimize the common case of a 3-way merge
if adds.len() == 2 {
// Optimize the common cases of 3-way merge and 1-way (non-)merge
if adds.len() == 1 {
return Some(&adds[0]);
} else if adds.len() == 2 {
return if adds[0] == adds[1] {
Some(&adds[0])
} else if adds[0] == removes[0] {