dev: use more safe retainer for gc (#817)

This commit is contained in:
Myriad-Dreamin 2024-11-14 21:21:27 +08:00 committed by GitHub
parent bbcca41909
commit dd2a22a67d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -218,22 +218,12 @@ impl LocalContextGuard {
break;
}
self.analysis
.caches
.def_signatures
.retain(|(l, _)| lifetime - *l < 60);
self.analysis
.caches
.static_signatures
.retain(|(l, _)| lifetime - *l < 60);
self.analysis
.caches
.terms
.retain(|(l, _)| lifetime - *l < 60);
self.analysis
.caches
.signatures
.retain(|(l, _)| lifetime - *l < 60);
let retainer = |l: u64| lifetime.saturating_sub(l) < 60;
let caches = &self.analysis.caches;
caches.def_signatures.retain(|(l, _)| retainer(*l));
caches.static_signatures.retain(|(l, _)| retainer(*l));
caches.terms.retain(|(l, _)| retainer(*l));
caches.signatures.retain(|(l, _)| retainer(*l));
}
}