mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
simplify edge counting
This commit is contained in:
parent
cb55f66b5b
commit
d29265759b
1 changed files with 12 additions and 3 deletions
|
@ -419,7 +419,6 @@ fn gather_edges<'a>(
|
||||||
|
|
||||||
let check = guarded_tests_are_complete(&relevant_tests);
|
let check = guarded_tests_are_complete(&relevant_tests);
|
||||||
|
|
||||||
// TODO remove clone
|
|
||||||
let all_edges = relevant_tests
|
let all_edges = relevant_tests
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|t| edges_for(path, &branches, t))
|
.map(|t| edges_for(path, &branches, t))
|
||||||
|
@ -1055,9 +1054,19 @@ fn small_defaults(branches: &[Branch], path: &[PathInstruction]) -> usize {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn small_branching_factor(branches: &[Branch], path: &[PathInstruction]) -> usize {
|
fn small_branching_factor(branches: &[Branch], path: &[PathInstruction]) -> usize {
|
||||||
let (edges, fallback) = gather_edges(branches.to_vec(), path);
|
// a specialized version of gather_edges that just counts the number of options
|
||||||
|
|
||||||
edges.len() + (if fallback.is_empty() { 0 } else { 1 })
|
let relevant_tests = tests_at_path(path, branches);
|
||||||
|
|
||||||
|
let check = guarded_tests_are_complete(&relevant_tests);
|
||||||
|
|
||||||
|
let fallbacks = if check {
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
branches.iter().any(|b| is_irrelevant_to(path, b))
|
||||||
|
};
|
||||||
|
|
||||||
|
relevant_tests.len() + (if !fallbacks { 0 } else { 1 })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue