use iterative rather than recursive method for following aliases (#573)
* use iterative rather than recursive method for following aliases * this avoids consuming stack via plain recursive calls
This commit is contained in:
committed by
Dan Gohman
parent
bf569b70dc
commit
a19c6088f0
@@ -283,10 +283,14 @@ fn write_value_aliases(
|
||||
target: Value,
|
||||
indent: usize,
|
||||
) -> fmt::Result {
|
||||
for &a in &aliases[target] {
|
||||
writeln!(w, "{1:0$}{2} -> {3}", indent, "", a, target)?;
|
||||
write_value_aliases(w, aliases, a, indent)?;
|
||||
let mut todo_stack = vec![target];
|
||||
while let Some(target) = todo_stack.pop() {
|
||||
for &a in &aliases[target] {
|
||||
writeln!(w, "{1:0$}{2} -> {3}", indent, "", a, target)?;
|
||||
todo_stack.push(a);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user