diff options
Diffstat (limited to 'compiler/rustc_incremental/src/persist/file_format.rs')
| -rw-r--r-- | compiler/rustc_incremental/src/persist/file_format.rs | 12 | 
1 files changed, 7 insertions, 5 deletions
diff --git a/compiler/rustc_incremental/src/persist/file_format.rs b/compiler/rustc_incremental/src/persist/file_format.rs index b821ed6cff9..501f6bdb9cf 100644 --- a/compiler/rustc_incremental/src/persist/file_format.rs +++ b/compiler/rustc_incremental/src/persist/file_format.rs @@ -14,6 +14,7 @@ use std::fs; use std::io::{self, Read}; use std::path::Path; +use rustc_data_structures::memmap::Mmap; use rustc_serialize::opaque::{FileEncodeResult, FileEncoder}; use rustc_serialize::Encoder; @@ -54,14 +55,15 @@ pub fn read_file( report_incremental_info: bool, path: &Path, nightly_build: bool, -) -> io::Result<Option<(Vec<u8>, usize)>> { - let data = match fs::read(path) { - Ok(data) => data, +) -> io::Result<Option<(Mmap, usize)>> { + let file = match fs::File::open(path) { + Ok(file) => file, Err(err) if err.kind() == io::ErrorKind::NotFound => return Ok(None), Err(err) => return Err(err), }; + let mmap = unsafe { Mmap::map(file) }?; - let mut file = io::Cursor::new(data); + let mut file = io::Cursor::new(&*mmap); // Check FILE_MAGIC { @@ -103,7 +105,7 @@ pub fn read_file( } let post_header_start_pos = file.position() as usize; - Ok(Some((file.into_inner(), post_header_start_pos))) + Ok(Some((mmap, post_header_start_pos))) } fn report_format_mismatch(report_incremental_info: bool, file: &Path, message: &str) {  | 
