From 644c383f65324b5fe1ada42680923c2529accb26 Mon Sep 17 00:00:00 2001 From: Michal Terepeta Date: Wed, 29 Jan 2020 20:55:35 +0100 Subject: A couple of small improvements to ra_prof printing Based on suggestions from @matklad. Signed-off-by: Michal Terepeta --- crates/ra_prof/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/ra_prof/src') diff --git a/crates/ra_prof/src/lib.rs b/crates/ra_prof/src/lib.rs index d95e7eb1b..e2c32c130 100644 --- a/crates/ra_prof/src/lib.rs +++ b/crates/ra_prof/src/lib.rs @@ -271,10 +271,10 @@ fn print_for_idx( /// In other words, a postorder of the call graph. In particular, the root is the last element of /// `msgs`. fn idx_to_children(msgs: &[Message]) -> Vec> { - // Initialize with the index of the root; `ancestors` should be never empty. + // Initialize with the index of the root; `msgs` and `ancestors` should be never empty. + assert!(!msgs.is_empty()); let mut ancestors = vec![msgs.len() - 1]; - let mut result: Vec> = vec![]; - result.resize_with(msgs.len(), Default::default); + let mut result: Vec> = vec![vec![]; msgs.len()]; for (idx, msg) in msgs[..msgs.len() - 1].iter().enumerate().rev() { // We need to find the parent of the current message, i.e., the last ancestor that has a // level lower than the current message. -- cgit v1.2.3