aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/status.rs15
1 files changed, 4 insertions, 11 deletions
diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs
index d533d1742..c037e496d 100644
--- a/crates/ra_ide_api/src/status.rs
+++ b/crates/ra_ide_api/src/status.rs
@@ -9,7 +9,7 @@ use ra_db::{
9 FileTextQuery, SourceRootId, 9 FileTextQuery, SourceRootId,
10}; 10};
11use ra_prof::{memory_usage, Bytes}; 11use ra_prof::{memory_usage, Bytes};
12use ra_syntax::{ast, AstNode, Parse, SyntaxNode}; 12use ra_syntax::{ast, Parse, SyntaxNode};
13 13
14use crate::{ 14use crate::{
15 db::RootDatabase, 15 db::RootDatabase,
@@ -70,12 +70,11 @@ impl FromIterator<TableEntry<FileId, Arc<String>>> for FilesStats {
70pub(crate) struct SyntaxTreeStats { 70pub(crate) struct SyntaxTreeStats {
71 total: usize, 71 total: usize,
72 pub(crate) retained: usize, 72 pub(crate) retained: usize,
73 retained_size: Bytes,
74} 73}
75 74
76impl fmt::Display for SyntaxTreeStats { 75impl fmt::Display for SyntaxTreeStats {
77 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { 76 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
78 write!(fmt, "{} trees, {} ({}) retained", self.total, self.retained, self.retained_size,) 77 write!(fmt, "{} trees, {} retained", self.total, self.retained)
79 } 78 }
80} 79}
81 80
@@ -87,10 +86,7 @@ impl FromIterator<TableEntry<FileId, Parse<ast::SourceFile>>> for SyntaxTreeStat
87 let mut res = SyntaxTreeStats::default(); 86 let mut res = SyntaxTreeStats::default();
88 for entry in iter { 87 for entry in iter {
89 res.total += 1; 88 res.total += 1;
90 if let Some(tree) = entry.value.as_ref().map(|it| it.tree()) { 89 res.retained += entry.value.is_some() as usize;
91 res.retained += 1;
92 res.retained_size += tree.syntax().memory_size_of_subtree();
93 }
94 } 90 }
95 res 91 res
96 } 92 }
@@ -104,10 +100,7 @@ impl FromIterator<TableEntry<MacroFile, Option<Parse<SyntaxNode>>>> for SyntaxTr
104 let mut res = SyntaxTreeStats::default(); 100 let mut res = SyntaxTreeStats::default();
105 for entry in iter { 101 for entry in iter {
106 res.total += 1; 102 res.total += 1;
107 if let Some(tree) = entry.value.and_then(|it| it).map(|it| it.syntax_node()) { 103 res.retained += entry.value.is_some() as usize;
108 res.retained += 1;
109 res.retained_size += tree.memory_size_of_subtree();
110 }
111 } 104 }
112 res 105 res
113 } 106 }