aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-19 17:56:24 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-19 17:56:24 +0100
commitd4ffbf2ae092b313b3c750adad398f3aa6fb209b (patch)
tree10d30f6688ffeb68827768b7c1790a198085faa9 /crates/ra_ide_api/src
parentf697d27c31ba4486b9711893a93505a05319a2dc (diff)
parent8f032d6a585d59a9d2e57beeaca903a4fb5eb57b (diff)
Merge #1555
1555: drop memory size of subtree r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src')
-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 }