Add GenericParams::shrink_to_fit
Reduces memory usage by over 10 MB
This commit is contained in:
parent
24e876b52e
commit
adcf18e27d
@ -218,6 +218,7 @@ impl GenericParams {
|
||||
GenericDefId::EnumVariantId(_) | GenericDefId::ConstId(_) => FileId(!0).into(),
|
||||
};
|
||||
|
||||
generics.shrink_to_fit();
|
||||
(generics, InFile::new(file_id, sm))
|
||||
}
|
||||
|
||||
@ -371,6 +372,14 @@ impl GenericParams {
|
||||
});
|
||||
}
|
||||
|
||||
pub(crate) fn shrink_to_fit(&mut self) {
|
||||
let Self { consts, lifetimes, types, where_predicates } = self;
|
||||
consts.shrink_to_fit();
|
||||
lifetimes.shrink_to_fit();
|
||||
types.shrink_to_fit();
|
||||
where_predicates.shrink_to_fit();
|
||||
}
|
||||
|
||||
pub fn find_type_by_name(&self, name: &Name) -> Option<LocalTypeParamId> {
|
||||
self.types
|
||||
.iter()
|
||||
|
@ -739,6 +739,7 @@ impl Ctx {
|
||||
}
|
||||
}
|
||||
|
||||
generics.shrink_to_fit();
|
||||
self.data().generics.alloc(generics)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user