diff options
| author | Ariel Ben-Yehuda <ariel.byd@gmail.com> | 2017-08-01 14:17:11 +0300 |
|---|---|---|
| committer | Ariel Ben-Yehuda <ariel.byd@gmail.com> | 2017-08-01 14:18:49 +0300 |
| commit | c9d14a846f4e34d2cf0db89423a32428ad8e924f (patch) | |
| tree | 1f14abe3ead139fc94cf7507421a17e5d18940ba /src/libsyntax/codemap.rs | |
| parent | 91aff5775d3b4a95e2b0c2fe50785f3d28fa3dd8 (diff) | |
| download | rust-c9d14a846f4e34d2cf0db89423a32428ad8e924f.tar.gz rust-c9d14a846f4e34d2cf0db89423a32428ad8e924f.zip | |
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.
Diffstat (limited to 'src/libsyntax/codemap.rs')
| -rw-r--r-- | src/libsyntax/codemap.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index b3d9cf9da36..bfdcae7641d 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -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() + ) } } |
