Auto merge of #129827 - bvanjoi:less-decoding, r=petrochenkov
perform less decoding if it has the same syntax context Following this [comment](https://github.com/rust-lang/rust/pull/127279#issuecomment-2210376603) r? `@petrochenkov`
This commit is contained in:
commit
d4812c8638
5 changed files with 80 additions and 157 deletions
|
@ -16,7 +16,7 @@ use rustc_serialize::opaque::{FileEncodeResult, FileEncoder, IntEncodedWithFixed
|
|||
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::hygiene::{
|
||||
ExpnId, HygieneDecodeContext, HygieneEncodeContext, SyntaxContext, SyntaxContextData,
|
||||
ExpnId, HygieneDecodeContext, HygieneEncodeContext, SyntaxContext, SyntaxContextKey,
|
||||
};
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::{
|
||||
|
@ -75,9 +75,9 @@ pub struct OnDiskCache {
|
|||
alloc_decoding_state: AllocDecodingState,
|
||||
|
||||
// A map from syntax context ids to the position of their associated
|
||||
// `SyntaxContextData`. We use a `u32` instead of a `SyntaxContext`
|
||||
// `SyntaxContextKey`. We use a `u32` instead of a `SyntaxContext`
|
||||
// to represent the fact that we are storing *encoded* ids. When we decode
|
||||
// a `SyntaxContext`, a new id will be allocated from the global `HygieneData`,
|
||||
// a `SyntaxContextKey`, a new id will be allocated from the global `HygieneData`,
|
||||
// which will almost certainly be different than the serialized id.
|
||||
syntax_contexts: FxHashMap<u32, AbsoluteBytePos>,
|
||||
// A map from the `DefPathHash` of an `ExpnId` to the position
|
||||
|
@ -305,7 +305,7 @@ impl OnDiskCache {
|
|||
let mut expn_data = UnhashMap::default();
|
||||
let mut foreign_expn_data = UnhashMap::default();
|
||||
|
||||
// Encode all hygiene data (`SyntaxContextData` and `ExpnData`) from the current
|
||||
// Encode all hygiene data (`SyntaxContextKey` and `ExpnData`) from the current
|
||||
// session.
|
||||
|
||||
hygiene_encode_context.encode(
|
||||
|
@ -566,7 +566,7 @@ impl<'a, 'tcx> SpanDecoder for CacheDecoder<'a, 'tcx> {
|
|||
// We look up the position of the associated `SyntaxData` and decode it.
|
||||
let pos = syntax_contexts.get(&id).unwrap();
|
||||
this.with_position(pos.to_usize(), |decoder| {
|
||||
let data: SyntaxContextData = decode_tagged(decoder, TAG_SYNTAX_CONTEXT);
|
||||
let data: SyntaxContextKey = decode_tagged(decoder, TAG_SYNTAX_CONTEXT);
|
||||
data
|
||||
})
|
||||
})
|
||||
|
|
|
@ -111,7 +111,7 @@ trivially_parameterized_over_tcx! {
|
|||
rustc_span::Span,
|
||||
rustc_span::Symbol,
|
||||
rustc_span::def_id::DefPathHash,
|
||||
rustc_span::hygiene::SyntaxContextData,
|
||||
rustc_span::hygiene::SyntaxContextKey,
|
||||
rustc_span::Ident,
|
||||
rustc_type_ir::Variance,
|
||||
rustc_hir::Attribute,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue