Skip to content

Commit

Permalink
Reduce branches of get_neighbours
Browse files Browse the repository at this point in the history
  • Loading branch information
QuarticCat committed Nov 21, 2022
1 parent 0eb70c8 commit 813a16c
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions src/diff/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,7 @@ pub fn get_neighbours<'syn, 'b>(
v.pop_rhs_cnt,
),
);
}

if let (
} else if let (
Syntax::List {
open_content: lhs_open_content,
close_content: lhs_close_content,
Expand Down Expand Up @@ -465,9 +463,7 @@ pub fn get_neighbours<'syn, 'b>(
),
);
}
}

if let (
} else if let (
Syntax::Atom {
content: lhs_content,
kind: AtomKind::Comment,
Expand All @@ -482,21 +478,19 @@ pub fn get_neighbours<'syn, 'b>(
{
// Both sides are comments and their content is reasonably
// similar.
if lhs_content != rhs_content {
let levenshtein_pct =
(normalized_levenshtein(lhs_content, rhs_content) * 100.0).round() as u8;
let levenshtein_pct =
(normalized_levenshtein(lhs_content, rhs_content) * 100.0).round() as u8;

add_neighbor(
ReplacedComment { levenshtein_pct },
next_vertex(
next_sibling(lhs_syntax),
next_sibling(rhs_syntax),
v.pop_both_ancestor,
v.pop_lhs_cnt,
v.pop_rhs_cnt,
),
);
}
add_neighbor(
ReplacedComment { levenshtein_pct },
next_vertex(
next_sibling(lhs_syntax),
next_sibling(rhs_syntax),
v.pop_both_ancestor,
v.pop_lhs_cnt,
v.pop_rhs_cnt,
),
);
}
}

Expand Down

0 comments on commit 813a16c

Please sign in to comment.