diff options
| author | Michael Woerister <michaelwoerister@posteo> | 2017-12-08 17:07:48 +0100 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo> | 2017-12-14 10:29:16 -0600 |
| commit | 0b4c2cccac30ebcd436e0cfd77b34019c40d4ce3 (patch) | |
| tree | 1762e549160fe7c4e8da05530fc7b06ad8ea691a /src/librustc | |
| parent | 9faa31612fb7a847a1c85836996846b9a6f20116 (diff) | |
| download | rust-0b4c2cccac30ebcd436e0cfd77b34019c40d4ce3.tar.gz rust-0b4c2cccac30ebcd436e0cfd77b34019c40d4ce3.zip | |
incr.comp.: Do less hashing per Span.
Diffstat (limited to 'src/librustc')
| -rw-r--r-- | src/librustc/ich/hcx.rs | 15 | ||||
| -rw-r--r-- | src/librustc/ich/impls_syntax.rs | 2 | ||||
| -rw-r--r-- | src/librustc/ty/maps/on_disk_cache.rs | 2 |
3 files changed, 12 insertions, 7 deletions
diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index 2d20836814c..f9fb668110b 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -338,13 +338,16 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for Span { return std_hash::Hash::hash(&TAG_INVALID_SPAN, hasher); } - let len = span.hi - span.lo; - std_hash::Hash::hash(&TAG_VALID_SPAN, hasher); - std_hash::Hash::hash(&file_lo.name, hasher); - std_hash::Hash::hash(&line_lo, hasher); - std_hash::Hash::hash(&col_lo, hasher); - std_hash::Hash::hash(&len, hasher); + // We truncate the stable_id hash and line and col numbers. The chances + // of causing a collision this way should be minimal. + std_hash::Hash::hash(&(file_lo.stable_id.0 as u64), hasher); + + let col = (col_lo.0 as u64) & 0xFF; + let line = ((line_lo as u64) & 0xFF_FF_FF) << 8; + let len = ((span.hi - span.lo).0 as u64) << 32; + let line_col_len = col | line | len; + std_hash::Hash::hash(&line_col_len, hasher); if span.ctxt == SyntaxContext::empty() { TAG_NO_EXPANSION.hash_stable(hcx, hasher); diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index c25aa10eb1e..dfb90a5d27f 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -394,6 +394,8 @@ impl<'gcx> HashStable<StableHashingContext<'gcx>> for FileMap { // Do not hash the source as it is not encoded src: _, src_hash, + // The stable id is just a hash of other fields + stable_id: _, external_src: _, start_pos, end_pos: _, diff --git a/src/librustc/ty/maps/on_disk_cache.rs b/src/librustc/ty/maps/on_disk_cache.rs index 079b518efd8..7d583a35477 100644 --- a/src/librustc/ty/maps/on_disk_cache.rs +++ b/src/librustc/ty/maps/on_disk_cache.rs @@ -176,7 +176,7 @@ impl<'sess> OnDiskCache<'sess> { let index = FileMapIndex(index as u32); let file_ptr: *const FileMap = &**file as *const _; file_to_file_index.insert(file_ptr, index); - file_index_to_stable_id.insert(index, StableFilemapId::new(&file)); + file_index_to_stable_id.insert(index, file.stable_id); } (file_to_file_index, file_index_to_stable_id) |
