simplify local_successors

This commit is contained in:
Folkert 2022-03-21 23:16:07 +01:00
parent cee1a787c9
commit 14b53c0ccf
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 10 additions and 21 deletions

View file

@ -438,11 +438,9 @@ pub fn sort_can_defs(
}
let mut defined_symbols: Vec<Symbol> = Vec::new();
let mut defined_symbols_set: ImSet<Symbol> = ImSet::default();
for symbol in can_defs_by_symbol.keys() {
defined_symbols.push(*symbol);
defined_symbols_set.insert(*symbol);
}
// Use topological sort to reorder the defs based on their dependencies to one another.
@ -490,7 +488,7 @@ pub fn sort_can_defs(
}
// remove anything that is not defined in the current block
loc_succ.retain(|key| defined_symbols_set.contains(key));
loc_succ.retain(|key| defined_symbols.contains(key));
loc_succ
}
@ -533,7 +531,7 @@ pub fn sort_can_defs(
}
// remove anything that is not defined in the current block
loc_succ.retain(|key| defined_symbols_set.contains(key));
loc_succ.retain(|key| defined_symbols.contains(key));
loc_succ
}
@ -552,7 +550,7 @@ pub fn sort_can_defs(
// NOTE: if the symbol is a closure we DONT look into its body
// remove anything that is not defined in the current block
loc_succ.retain(|key| defined_symbols_set.contains(key));
loc_succ.retain(|key| defined_symbols.contains(key));
// NOTE: direct recursion does matter here: `x = x` is invalid recursion!