mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-22 12:34:39 +00:00
feat: improve caches of calls and module exports type checking (#847)
* dev: optimize log on critical paths * dev: optimize `check_module_item` * dev: cache source queries * dev: cache call checking * dev: remove source cache
This commit is contained in:
parent
256dd3b3a5
commit
ccd3cea08c
5 changed files with 107 additions and 33 deletions
|
|
@ -533,7 +533,7 @@ impl SharedContext {
|
|||
|
||||
/// Get the source of a file by file path.
|
||||
pub fn source_by_path(&self, p: &Path) -> FileResult<Source> {
|
||||
self.world.source_by_path(p)
|
||||
self.source_by_id(self.file_id_by_path(p)?)
|
||||
}
|
||||
|
||||
/// Get a syntax object at a position.
|
||||
|
|
@ -1114,16 +1114,26 @@ pub struct AnalysisRevCache {
|
|||
impl RevisionManagerLike for AnalysisRevCache {
|
||||
fn gc(&mut self, rev: usize) {
|
||||
self.manager.gc(rev);
|
||||
self.default_slot
|
||||
.expr_stage
|
||||
.global
|
||||
.lock()
|
||||
.retain(|_, r| r.0 >= rev);
|
||||
self.default_slot
|
||||
.type_check
|
||||
.global
|
||||
.lock()
|
||||
.retain(|_, r| r.0 >= rev);
|
||||
|
||||
{
|
||||
let mut max_ei = FxHashMap::default();
|
||||
let es = self.default_slot.expr_stage.global.lock();
|
||||
for r in es.iter() {
|
||||
let rev: &mut usize = max_ei.entry(r.1.fid).or_default();
|
||||
*rev = (*rev).max(r.1.revision);
|
||||
}
|
||||
es.retain(|_, r| r.1.revision == *max_ei.get(&r.1.fid).unwrap_or(&0));
|
||||
}
|
||||
|
||||
{
|
||||
let mut max_ti = FxHashMap::default();
|
||||
let ts = self.default_slot.type_check.global.lock();
|
||||
for r in ts.iter() {
|
||||
let rev: &mut usize = max_ti.entry(r.1.fid).or_default();
|
||||
*rev = (*rev).max(r.1.revision);
|
||||
}
|
||||
ts.retain(|_, r| r.1.revision == *max_ti.get(&r.1.fid).unwrap_or(&0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue