Skip to content

Commit 644c383

Browse files
committed
A couple of small improvements to ra_prof printing
Based on suggestions from @matklad. Signed-off-by: Michal Terepeta <[email protected]>
1 parent 39cbb6b commit 644c383

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

crates/ra_prof/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ fn print_for_idx(
271271
/// In other words, a postorder of the call graph. In particular, the root is the last element of
272272
/// `msgs`.
273273
fn idx_to_children(msgs: &[Message]) -> Vec<Vec<usize>> {
274-
// Initialize with the index of the root; `ancestors` should be never empty.
274+
// Initialize with the index of the root; `msgs` and `ancestors` should be never empty.
275+
assert!(!msgs.is_empty());
275276
let mut ancestors = vec![msgs.len() - 1];
276-
let mut result: Vec<Vec<usize>> = vec![];
277-
result.resize_with(msgs.len(), Default::default);
277+
let mut result: Vec<Vec<usize>> = vec![vec![]; msgs.len()];
278278
for (idx, msg) in msgs[..msgs.len() - 1].iter().enumerate().rev() {
279279
// We need to find the parent of the current message, i.e., the last ancestor that has a
280280
// level lower than the current message.

0 commit comments

Comments
 (0)