diff options
| author | Josh Stone <jistone@redhat.com> | 2025-02-26 20:47:53 -0800 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2025-03-10 17:08:30 -0700 |
| commit | 3b0c2585c8daec44877a38fd83edaf1888afe7f9 (patch) | |
| tree | dcdac774c95f0089ed156981520a71ff2275e19d /compiler/rustc_query_system/src/query | |
| parent | 9fb94b32df38073bf63d009df77ed10cb1c989d0 (diff) | |
| download | rust-3b0c2585c8daec44877a38fd83edaf1888afe7f9.tar.gz rust-3b0c2585c8daec44877a38fd83edaf1888afe7f9.zip | |
Convert `ShardedHashMap` to use `hashbrown::HashTable`
The `hash_raw_entry` feature has finished fcp-close, so the compiler should stop using it to allow its removal. Several `Sharded` maps were using raw entries to avoid re-hashing between shard and map lookup, and we can do that with `hashbrown::HashTable` instead.
Diffstat (limited to 'compiler/rustc_query_system/src/query')
| -rw-r--r-- | compiler/rustc_query_system/src/query/caches.rs | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/compiler/rustc_query_system/src/query/caches.rs b/compiler/rustc_query_system/src/query/caches.rs index 3b47e7eba0f..30b5d7e5954 100644 --- a/compiler/rustc_query_system/src/query/caches.rs +++ b/compiler/rustc_query_system/src/query/caches.rs @@ -2,8 +2,7 @@ use std::fmt::Debug; use std::hash::Hash; use std::sync::OnceLock; -use rustc_data_structures::fx::FxHashMap; -use rustc_data_structures::sharded::{self, Sharded}; +use rustc_data_structures::sharded::ShardedHashMap; pub use rustc_data_structures::vec_cache::VecCache; use rustc_hir::def_id::LOCAL_CRATE; use rustc_index::Idx; @@ -36,7 +35,7 @@ pub trait QueryCache: Sized { /// In-memory cache for queries whose keys aren't suitable for any of the /// more specialized kinds of cache. Backed by a sharded hashmap. pub struct DefaultCache<K, V> { - cache: Sharded<FxHashMap<K, (V, DepNodeIndex)>>, + cache: ShardedHashMap<K, (V, DepNodeIndex)>, } impl<K, V> Default for DefaultCache<K, V> { @@ -55,19 +54,14 @@ where #[inline(always)] fn lookup(&self, key: &K) -> Option<(V, DepNodeIndex)> { - let key_hash = sharded::make_hash(key); - let lock = self.cache.lock_shard_by_hash(key_hash); - let result = lock.raw_entry().from_key_hashed_nocheck(key_hash, key); - - if let Some((_, value)) = result { Some(*value) } else { None } + self.cache.get(key) } #[inline] fn complete(&self, key: K, value: V, index: DepNodeIndex) { - let mut lock = self.cache.lock_shard_by_value(&key); // We may be overwriting another value. This is all right, since the dep-graph // will check that the fingerprint matches. - lock.insert(key, (value, index)); + self.cache.insert(key, (value, index)); } fn iter(&self, f: &mut dyn FnMut(&Self::Key, &Self::Value, DepNodeIndex)) { |
