incr.comp.: Do less hashing per Span.
This commit is contained in:
parent
9faa31612f
commit
0b4c2cccac
6 changed files with 62 additions and 41 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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: _,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue