mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
A couple of small improvements to ra_prof printing
Based on suggestions from @matklad. Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
This commit is contained in:
parent
39cbb6b620
commit
644c383f65
1 changed files with 3 additions and 3 deletions
|
@ -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
|
/// In other words, a postorder of the call graph. In particular, the root is the last element of
|
||||||
/// `msgs`.
|
/// `msgs`.
|
||||||
fn idx_to_children(msgs: &[Message]) -> Vec<Vec<usize>> {
|
fn idx_to_children(msgs: &[Message]) -> Vec<Vec<usize>> {
|
||||||
// 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 ancestors = vec![msgs.len() - 1];
|
||||||
let mut result: Vec<Vec<usize>> = vec![];
|
let mut result: Vec<Vec<usize>> = vec![vec![]; msgs.len()];
|
||||||
result.resize_with(msgs.len(), Default::default);
|
|
||||||
for (idx, msg) in msgs[..msgs.len() - 1].iter().enumerate().rev() {
|
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
|
// We need to find the parent of the current message, i.e., the last ancestor that has a
|
||||||
// level lower than the current message.
|
// level lower than the current message.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue