syntax: avoid loading the same source-file multiple times
We already had a cache for file contents, but we read the source-file before testing the cache, causing obvious slowness, so this just avoids loading the source-file when the cache already has the contents.
This commit is contained in:
@@ -561,8 +561,9 @@ impl CodeMapper for CodeMap {
|
||||
sp
|
||||
}
|
||||
fn ensure_filemap_source_present(&self, file_map: Rc<FileMap>) -> bool {
|
||||
let src = self.file_loader.read_file(Path::new(&file_map.name)).ok();
|
||||
return file_map.add_external_src(src)
|
||||
file_map.add_external_src(
|
||||
|| self.file_loader.read_file(Path::new(&file_map.name)).ok()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user