mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-16 12:44:27 +00:00
diff: remove redundant check for empty ranges from unchanged_ranges() recursion
It's cheap to create an empty Vec, and I'm going to remove it anyway.
This commit is contained in:
parent
fd2c377a4a
commit
f6277bbdb8
@ -289,30 +289,22 @@ fn unchanged_ranges_lcs(
|
|||||||
for (left_index, right_index) in lcs {
|
for (left_index, right_index) in lcs {
|
||||||
let (left_position, _) = left_positions[left_index];
|
let (left_position, _) = left_positions[left_index];
|
||||||
let (right_position, _) = right_positions[right_index];
|
let (right_position, _) = right_positions[right_index];
|
||||||
let skipped_left_positions = previous_left_position..left_position;
|
for unchanged_nested_range in unchanged_ranges(
|
||||||
let skipped_right_positions = previous_right_position..right_position;
|
&left.narrowed(previous_left_position..left_position),
|
||||||
if !skipped_left_positions.is_empty() || !skipped_right_positions.is_empty() {
|
&right.narrowed(previous_right_position..right_position),
|
||||||
for unchanged_nested_range in unchanged_ranges(
|
) {
|
||||||
&left.narrowed(skipped_left_positions.clone()),
|
result.push(unchanged_nested_range);
|
||||||
&right.narrowed(skipped_right_positions.clone()),
|
|
||||||
) {
|
|
||||||
result.push(unchanged_nested_range);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
result.push((left.range_at(left_position), right.range_at(right_position)));
|
result.push((left.range_at(left_position), right.range_at(right_position)));
|
||||||
previous_left_position = WordPosition(left_position.0 + 1);
|
previous_left_position = WordPosition(left_position.0 + 1);
|
||||||
previous_right_position = WordPosition(right_position.0 + 1);
|
previous_right_position = WordPosition(right_position.0 + 1);
|
||||||
}
|
}
|
||||||
// Also recurse into range at end (after common ranges).
|
// Also recurse into range at end (after common ranges).
|
||||||
let skipped_left_positions = previous_left_position..WordPosition(left.ranges.len());
|
for unchanged_nested_range in unchanged_ranges(
|
||||||
let skipped_right_positions = previous_right_position..WordPosition(right.ranges.len());
|
&left.narrowed(previous_left_position..WordPosition(left.ranges.len())),
|
||||||
if !skipped_left_positions.is_empty() || !skipped_right_positions.is_empty() {
|
&right.narrowed(previous_right_position..WordPosition(right.ranges.len())),
|
||||||
for unchanged_nested_range in unchanged_ranges(
|
) {
|
||||||
&left.narrowed(skipped_left_positions),
|
result.push(unchanged_nested_range);
|
||||||
&right.narrowed(skipped_right_positions),
|
|
||||||
) {
|
|
||||||
result.push(unchanged_nested_range);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
|
Loading…
x
Reference in New Issue
Block a user