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,
|
target: Value,
|
||||||
indent: usize,
|
indent: usize,
|
||||||
) -> fmt::Result {
|
) -> fmt::Result {
|
||||||
for &a in &aliases[target] {
|
let mut todo_stack = vec![target];
|
||||||
writeln!(w, "{1:0$}{2} -> {3}", indent, "", a, target)?;
|
while let Some(target) = todo_stack.pop() {
|
||||||
write_value_aliases(w, aliases, a, indent)?;
|
for &a in &aliases[target] {
|
||||||
|
writeln!(w, "{1:0$}{2} -> {3}", indent, "", a, target)?;
|
||||||
|
todo_stack.push(a);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,12 +84,12 @@ where
|
|||||||
Keys::with_len(self.elems.len())
|
Keys::with_len(self.elems.len())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterate over all the keys in this map.
|
/// Iterate over all the values in this map.
|
||||||
pub fn values(&self) -> slice::Iter<V> {
|
pub fn values(&self) -> slice::Iter<V> {
|
||||||
self.elems.iter()
|
self.elems.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Iterate over all the keys in this map, mutable edition.
|
/// Iterate over all the values in this map, mutable edition.
|
||||||
pub fn values_mut(&mut self) -> slice::IterMut<V> {
|
pub fn values_mut(&mut self) -> slice::IterMut<V> {
|
||||||
self.elems.iter_mut()
|
self.elems.iter_mut()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user