aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-18 22:11:36 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-18 22:11:36 +0000
commit9664fbcac5e53d725c6e438ffba2194921321b76 (patch)
tree2a10781f93c8e994d64d331b1c0d25ce84529041 /crates
parentd05790b9478705c47c9de34bfdee08f823e4e92f (diff)
parentd20d788571b9d1b5f4b9a386b8ca82ee0b278c17 (diff)
Merge #289
289: WIP: fix accidently quadratic behavior r=matklad a=matklad we've recmoputed item map every time previously :man_facepalming: :man_facepalming: :man_facepalming: Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_analysis/src/imp.rs25
-rw-r--r--crates/ra_hir/src/db.rs4
2 files changed, 21 insertions, 8 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index 03d17de0d..0de0e2645 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -10,7 +10,7 @@ use ra_syntax::{
10 SyntaxKind::*, 10 SyntaxKind::*,
11 SyntaxNodeRef, TextRange, TextUnit, 11 SyntaxNodeRef, TextRange, TextUnit,
12}; 12};
13use ra_db::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE, SyntaxDatabase, SourceFileQuery}; 13use ra_db::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE, SyntaxDatabase};
14use rayon::prelude::*; 14use rayon::prelude::*;
15use rustc_hash::FxHashSet; 15use rustc_hash::FxHashSet;
16use salsa::{Database, ParallelDatabase}; 16use salsa::{Database, ParallelDatabase};
@@ -43,6 +43,7 @@ impl AnalysisHostImpl {
43 } 43 }
44 pub fn apply_change(&mut self, change: AnalysisChange) { 44 pub fn apply_change(&mut self, change: AnalysisChange) {
45 log::info!("apply_change {:?}", change); 45 log::info!("apply_change {:?}", change);
46 // self.gc_syntax_trees();
46 47
47 for (file_id, text) in change.files_changed { 48 for (file_id, text) in change.files_changed {
48 self.db 49 self.db
@@ -115,6 +116,25 @@ impl AnalysisHostImpl {
115 .set((), Arc::new(crate_graph)) 116 .set((), Arc::new(crate_graph))
116 } 117 }
117 } 118 }
119
120 #[allow(unused)]
121 /// Ideally, we should call this function from time to time to collect heavy
122 /// syntax trees. However, if we actually do that, everything is recomputed
123 /// for some reason. Needs investigation.
124 fn gc_syntax_trees(&mut self) {
125 self.db
126 .query(ra_db::SourceFileQuery)
127 .sweep(salsa::SweepStrategy::default().discard_values());
128 self.db
129 .query(hir::db::FnSyntaxQuery)
130 .sweep(salsa::SweepStrategy::default().discard_values());
131 self.db
132 .query(hir::db::SourceFileItemsQuery)
133 .sweep(salsa::SweepStrategy::default().discard_values());
134 self.db
135 .query(hir::db::FileItemQuery)
136 .sweep(salsa::SweepStrategy::default().discard_values());
137 }
118} 138}
119 139
120pub(crate) struct AnalysisImpl { 140pub(crate) struct AnalysisImpl {
@@ -160,9 +180,6 @@ impl AnalysisImpl {
160 .filter_map(|it| it.ok()) 180 .filter_map(|it| it.ok())
161 .collect() 181 .collect()
162 }; 182 };
163 self.db
164 .query(SourceFileQuery)
165 .sweep(salsa::SweepStrategy::default().discard_values());
166 Ok(query.search(&buf)) 183 Ok(query.search(&buf))
167 } 184 }
168 /// This returns `Vec` because a module may be included from several places. We 185 /// This returns `Vec` because a module may be included from several places. We
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index ff41fd326..62cf9ab17 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -27,20 +27,16 @@ pub trait HirDatabase: SyntaxDatabase
27 } 27 }
28 fn fn_syntax(fn_id: FnId) -> FnDefNode { 28 fn fn_syntax(fn_id: FnId) -> FnDefNode {
29 type FnSyntaxQuery; 29 type FnSyntaxQuery;
30 // Don't retain syntax trees in memory
31 storage dependencies;
32 use fn query_definitions::fn_syntax; 30 use fn query_definitions::fn_syntax;
33 } 31 }
34 32
35 fn file_items(file_id: FileId) -> Arc<SourceFileItems> { 33 fn file_items(file_id: FileId) -> Arc<SourceFileItems> {
36 type SourceFileItemsQuery; 34 type SourceFileItemsQuery;
37 storage dependencies;
38 use fn query_definitions::file_items; 35 use fn query_definitions::file_items;
39 } 36 }
40 37
41 fn file_item(source_item_id: SourceItemId) -> SyntaxNode { 38 fn file_item(source_item_id: SourceItemId) -> SyntaxNode {
42 type FileItemQuery; 39 type FileItemQuery;
43 storage dependencies;
44 use fn query_definitions::file_item; 40 use fn query_definitions::file_item;
45 } 41 }
46 42