1
Fork 0

Make DefIdForest cheaper to clone

Since `DefIdForest` contains 0 or 1 elements the large majority of the
time, by allocating only in the >1 case we avoid almost all allocations,
compared to `Arc<SmallVec<[DefId;1]>>`. This shaves off 0.2% on the
benchmark that stresses uninhabitedness checking.
This commit is contained in:
Nadrieril 2020-12-03 01:52:24 +00:00
parent 8598c9f6e5
commit e608d8f4e5
3 changed files with 80 additions and 58 deletions

View file

@ -1314,7 +1314,7 @@ rustc_queries! {
/// check whether the forest is empty.
query type_uninhabited_from(
key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
) -> Arc<ty::inhabitedness::DefIdForest> {
) -> ty::inhabitedness::DefIdForest {
desc { "computing the inhabitedness of `{:?}`", key }
}
}