fix(els): caching bugs

This commit is contained in:
Shunsuke Shibayama 2023-08-21 17:00:25 +09:00
parent f2ad45878a
commit 82792aca80
8 changed files with 68 additions and 6 deletions

View file

@ -61,6 +61,15 @@ impl TraitImpls {
self.cache.remove(path)
}
pub fn rename<Q: Eq + Hash + ?Sized>(&mut self, old: &Q, new: Str)
where
Str: Borrow<Q>,
{
if let Some(impls) = self.remove(old) {
self.register(new, impls);
}
}
pub fn initialize(&mut self) {
self.cache.clear();
}
@ -123,6 +132,13 @@ impl SharedTraitImpls {
self.0.borrow_mut().remove(path)
}
pub fn rename<Q: Eq + Hash + ?Sized>(&self, old: &Q, new: Str)
where
Str: Borrow<Q>,
{
self.0.borrow_mut().rename(old, new);
}
pub fn ref_inner(&self) -> MappedRwLockReadGuard<Dict<Str, Set<TraitImpl>>> {
RwLockReadGuard::map(self.0.borrow(), |tis| &tis.cache)
}