diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-05-25 14:01:18 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-05-26 08:56:49 +1000 |
| commit | 2b91c40c19e51b694ec113fd6991cf59959d4046 (patch) | |
| tree | b32895c88922e4f2e7216209de60f46aa07cc7ff /compiler/rustc_metadata/src | |
| parent | 3e810c64d091112cf8ac51a533068632fad30a8d (diff) | |
| download | rust-2b91c40c19e51b694ec113fd6991cf59959d4046.tar.gz rust-2b91c40c19e51b694ec113fd6991cf59959d4046.zip | |
Avoid adjusting file positions twice.
`imported_source_files` adjusts lots of file positions, and then calls `new_imported_source_file`, which then adjust them all again. This commit combines the two adjustments into one, for a small perf win.
Diffstat (limited to 'compiler/rustc_metadata/src')
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder.rs | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index 4038af38a2c..1624e6cd6ee 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1639,10 +1639,10 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { src_hash, start_pos, end_pos, - mut lines, - mut multibyte_chars, - mut non_narrow_chars, - mut normalized_pos, + lines, + multibyte_chars, + non_narrow_chars, + normalized_pos, name_hash, .. } = source_file_to_import; @@ -1679,24 +1679,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { let source_length = (end_pos - start_pos).to_usize(); - // Translate line-start positions and multibyte character - // position into frame of reference local to file. - // `SourceMap::new_imported_source_file()` will then translate those - // coordinates to their new global frame of reference when the - // offset of the SourceFile is known. - for pos in &mut lines { - *pos = *pos - start_pos; - } - for mbc in &mut multibyte_chars { - mbc.pos = mbc.pos - start_pos; - } - for swc in &mut non_narrow_chars { - *swc = *swc - start_pos; - } - for np in &mut normalized_pos { - np.pos = np.pos - start_pos; - } - let local_version = sess.source_map().new_imported_source_file( name, src_hash, |
