Rollup merge of #133547 - cuviper:span-set-entry, r=jieyouxu
rustc_span: Replace a `HashMap<_, ()>` with `HashSet` Now that `HashSet::entry()` exists, we don't need to fake it with a map.
This commit is contained in:
commit
63a6e9c907
2 changed files with 7 additions and 5 deletions
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
|
use std::collections::hash_set::Entry as SetEntry;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
|
@ -1270,7 +1271,7 @@ pub struct HygieneDecodeContext {
|
||||||
inner: Lock<HygieneDecodeContextInner>,
|
inner: Lock<HygieneDecodeContextInner>,
|
||||||
|
|
||||||
/// A set of serialized `SyntaxContext` ids that are currently being decoded on each thread.
|
/// A set of serialized `SyntaxContext` ids that are currently being decoded on each thread.
|
||||||
local_in_progress: WorkerLocal<RefCell<FxHashMap<u32, ()>>>,
|
local_in_progress: WorkerLocal<RefCell<FxHashSet<u32>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Register an expansion which has been decoded from the on-disk-cache for the local crate.
|
/// Register an expansion which has been decoded from the on-disk-cache for the local crate.
|
||||||
|
@ -1364,14 +1365,14 @@ pub fn decode_syntax_context<D: Decoder, F: FnOnce(&mut D, u32) -> SyntaxContext
|
||||||
match inner.decoding.entry(raw_id) {
|
match inner.decoding.entry(raw_id) {
|
||||||
Entry::Occupied(ctxt_entry) => {
|
Entry::Occupied(ctxt_entry) => {
|
||||||
match context.local_in_progress.borrow_mut().entry(raw_id) {
|
match context.local_in_progress.borrow_mut().entry(raw_id) {
|
||||||
Entry::Occupied(..) => {
|
SetEntry::Occupied(..) => {
|
||||||
// We're decoding this already on the current thread. Return here
|
// We're decoding this already on the current thread. Return here
|
||||||
// and let the function higher up the stack finish decoding to handle
|
// and let the function higher up the stack finish decoding to handle
|
||||||
// recursive cases.
|
// recursive cases.
|
||||||
return *ctxt_entry.get();
|
return *ctxt_entry.get();
|
||||||
}
|
}
|
||||||
Entry::Vacant(entry) => {
|
SetEntry::Vacant(entry) => {
|
||||||
entry.insert(());
|
entry.insert();
|
||||||
|
|
||||||
// Some other thread is current decoding this. Race with it.
|
// Some other thread is current decoding this. Race with it.
|
||||||
*ctxt_entry.get()
|
*ctxt_entry.get()
|
||||||
|
@ -1380,7 +1381,7 @@ pub fn decode_syntax_context<D: Decoder, F: FnOnce(&mut D, u32) -> SyntaxContext
|
||||||
}
|
}
|
||||||
Entry::Vacant(entry) => {
|
Entry::Vacant(entry) => {
|
||||||
// We are the first thread to start decoding. Mark the current thread as being progress.
|
// We are the first thread to start decoding. Mark the current thread as being progress.
|
||||||
context.local_in_progress.borrow_mut().insert(raw_id, ());
|
context.local_in_progress.borrow_mut().insert(raw_id);
|
||||||
|
|
||||||
// Allocate and store SyntaxContext id *before* calling the decoder function,
|
// Allocate and store SyntaxContext id *before* calling the decoder function,
|
||||||
// as the SyntaxContextData may reference itself.
|
// as the SyntaxContextData may reference itself.
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#![feature(array_windows)]
|
#![feature(array_windows)]
|
||||||
#![feature(cfg_match)]
|
#![feature(cfg_match)]
|
||||||
#![feature(core_io_borrowed_buf)]
|
#![feature(core_io_borrowed_buf)]
|
||||||
|
#![feature(hash_set_entry)]
|
||||||
#![feature(if_let_guard)]
|
#![feature(if_let_guard)]
|
||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
#![feature(min_specialization)]
|
#![feature(min_specialization)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue