mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Add GenericParams::shrink_to_fit
Reduces memory usage by over 10 MB
This commit is contained in:
parent
24e876b52e
commit
adcf18e27d
2 changed files with 10 additions and 0 deletions
|
@ -218,6 +218,7 @@ impl GenericParams {
|
||||||
GenericDefId::EnumVariantId(_) | GenericDefId::ConstId(_) => FileId(!0).into(),
|
GenericDefId::EnumVariantId(_) | GenericDefId::ConstId(_) => FileId(!0).into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
generics.shrink_to_fit();
|
||||||
(generics, InFile::new(file_id, sm))
|
(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> {
|
pub fn find_type_by_name(&self, name: &Name) -> Option<LocalTypeParamId> {
|
||||||
self.types
|
self.types
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -739,6 +739,7 @@ impl Ctx {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generics.shrink_to_fit();
|
||||||
self.data().generics.alloc(generics)
|
self.data().generics.alloc(generics)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue