mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-26 14:06:13 +00:00
conflicts: simplify inner loop of simplify() a bit
This commit is contained in:
parent
aac5b7aa25
commit
afb1e1693e
1 changed files with 7 additions and 13 deletions
|
@ -98,19 +98,13 @@ impl<T> Conflict<T> {
|
||||||
let mut add_index = 0;
|
let mut add_index = 0;
|
||||||
while add_index < self.adds.len() {
|
while add_index < self.adds.len() {
|
||||||
let add = &self.adds[add_index];
|
let add = &self.adds[add_index];
|
||||||
let mut modified = false;
|
if let Some(remove_index) = self.removes.iter().position(|remove| remove == add) {
|
||||||
for (remove_index, remove) in self.removes.iter().enumerate() {
|
// Move the value to the `add_index-1`th diff, then delete the `remove_index`th
|
||||||
if remove == add {
|
// diff.
|
||||||
// Move the value to the `add_index-1`th diff, then delete the `remove_index`th
|
self.adds.swap(remove_index + 1, add_index);
|
||||||
// diff.
|
self.removes.remove(remove_index);
|
||||||
self.adds.swap(remove_index + 1, add_index);
|
self.adds.remove(remove_index + 1);
|
||||||
self.removes.remove(remove_index);
|
} else {
|
||||||
self.adds.remove(remove_index + 1);
|
|
||||||
modified = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !modified {
|
|
||||||
add_index += 1;
|
add_index += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue