Remove CacheSelector
trait now that we can use GATs
This commit is contained in:
parent
73476d4990
commit
3b94f33c23
5 changed files with 57 additions and 102 deletions
|
@ -9,13 +9,6 @@ use rustc_span::def_id::DefId;
|
|||
use rustc_span::def_id::DefIndex;
|
||||
use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
pub trait CacheSelector<'tcx, V> {
|
||||
type Cache
|
||||
where
|
||||
V: Copy;
|
||||
}
|
||||
|
||||
pub trait QueryCache: Sized {
|
||||
type Key: Hash + Eq + Copy + Debug;
|
||||
|
@ -29,14 +22,6 @@ pub trait QueryCache: Sized {
|
|||
fn iter(&self, f: &mut dyn FnMut(&Self::Key, &Self::Value, DepNodeIndex));
|
||||
}
|
||||
|
||||
pub struct DefaultCacheSelector<K>(PhantomData<K>);
|
||||
|
||||
impl<'tcx, K: Eq + Hash, V: 'tcx> CacheSelector<'tcx, V> for DefaultCacheSelector<K> {
|
||||
type Cache = DefaultCache<K, V>
|
||||
where
|
||||
V: Copy;
|
||||
}
|
||||
|
||||
pub struct DefaultCache<K, V> {
|
||||
cache: Sharded<FxHashMap<K, (V, DepNodeIndex)>>,
|
||||
}
|
||||
|
@ -81,14 +66,6 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
pub struct SingleCacheSelector;
|
||||
|
||||
impl<'tcx, V: 'tcx> CacheSelector<'tcx, V> for SingleCacheSelector {
|
||||
type Cache = SingleCache<V>
|
||||
where
|
||||
V: Copy;
|
||||
}
|
||||
|
||||
pub struct SingleCache<V> {
|
||||
cache: OnceLock<(V, DepNodeIndex)>,
|
||||
}
|
||||
|
@ -123,14 +100,6 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
pub struct VecCacheSelector<K>(PhantomData<K>);
|
||||
|
||||
impl<'tcx, K: Idx, V: 'tcx> CacheSelector<'tcx, V> for VecCacheSelector<K> {
|
||||
type Cache = VecCache<K, V>
|
||||
where
|
||||
V: Copy;
|
||||
}
|
||||
|
||||
pub struct VecCache<K: Idx, V> {
|
||||
cache: Sharded<IndexVec<K, Option<(V, DepNodeIndex)>>>,
|
||||
}
|
||||
|
@ -174,14 +143,6 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
pub struct DefIdCacheSelector;
|
||||
|
||||
impl<'tcx, V: 'tcx> CacheSelector<'tcx, V> for DefIdCacheSelector {
|
||||
type Cache = DefIdCache<V>
|
||||
where
|
||||
V: Copy;
|
||||
}
|
||||
|
||||
pub struct DefIdCache<V> {
|
||||
/// Stores the local DefIds in a dense map. Local queries are much more often dense, so this is
|
||||
/// a win over hashing query keys at marginal memory cost (~5% at most) compared to FxHashMap.
|
||||
|
|
|
@ -9,10 +9,7 @@ pub use self::job::{
|
|||
};
|
||||
|
||||
mod caches;
|
||||
pub use self::caches::{
|
||||
CacheSelector, DefIdCacheSelector, DefaultCacheSelector, QueryCache, SingleCacheSelector,
|
||||
VecCacheSelector,
|
||||
};
|
||||
pub use self::caches::{DefIdCache, DefaultCache, QueryCache, SingleCache, VecCache};
|
||||
|
||||
mod config;
|
||||
pub use self::config::{HashResult, QueryConfig};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue