1
Fork 0

Free some memory instead of just dropping elements

This commit is contained in:
Oliver Scherer 2018-10-16 19:59:44 +02:00
parent 55f76628ee
commit ab3f37ec43
2 changed files with 6 additions and 3 deletions

View file

@ -3789,14 +3789,16 @@ impl<'tcx> TraitObligation<'tcx> {
}
impl<'tcx> SelectionCache<'tcx> {
/// Actually frees the underlying memory in contrast to what stdlib containers do on `clear`
pub fn clear(&self) {
self.hashmap.borrow_mut().clear();
*self.hashmap.borrow_mut() = Default::default();
}
}
impl<'tcx> EvaluationCache<'tcx> {
/// Actually frees the underlying memory in contrast to what stdlib containers do on `clear`
pub fn clear(&self) {
self.hashmap.borrow_mut().clear();
*self.hashmap.borrow_mut() = Default::default();
}
}

View file

@ -398,7 +398,8 @@ impl Handler {
/// tools that want to reuse a `Parser` cleaning the previously emitted diagnostics as well as
/// the overall count of emitted error diagnostics.
pub fn reset_err_count(&self) {
self.emitted_diagnostics.borrow_mut().clear();
// actually frees the underlying memory (which `clear` would not do)
*self.emitted_diagnostics.borrow_mut() = Default::default();
self.err_count.store(0, SeqCst);
}