Collect directly into ThinVec
This commit is contained in:
parent
e90f129adf
commit
3814ec5b16
2 changed files with 7 additions and 9 deletions
|
@ -516,8 +516,7 @@ fn projection_to_path_segment<'tcx>(
|
|||
ty.map_bound(|ty| &ty.args[generics.parent_count..]),
|
||||
false,
|
||||
def_id,
|
||||
)
|
||||
.into(),
|
||||
),
|
||||
constraints: Default::default(),
|
||||
},
|
||||
}
|
||||
|
@ -2202,8 +2201,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
|
|||
alias_ty.map_bound(|ty| ty.args.as_slice()),
|
||||
true,
|
||||
def_id,
|
||||
)
|
||||
.into(),
|
||||
),
|
||||
constraints: Default::default(),
|
||||
},
|
||||
},
|
||||
|
@ -2521,7 +2519,7 @@ fn clean_generic_args<'tcx>(
|
|||
) -> GenericArgs {
|
||||
// FIXME(return_type_notation): Fix RTN parens rendering
|
||||
if let Some((inputs, output)) = generic_args.paren_sugar_inputs_output() {
|
||||
let inputs = inputs.iter().map(|x| clean_ty(x, cx)).collect::<Vec<_>>().into();
|
||||
let inputs = inputs.iter().map(|x| clean_ty(x, cx)).collect::<ThinVec<_>>().into();
|
||||
let output = match output.kind {
|
||||
hir::TyKind::Tup(&[]) => None,
|
||||
_ => Some(Box::new(clean_ty(output, cx))),
|
||||
|
@ -2542,7 +2540,7 @@ fn clean_generic_args<'tcx>(
|
|||
}
|
||||
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.collect::<ThinVec<_>>()
|
||||
.into();
|
||||
let constraints = generic_args
|
||||
.constraints
|
||||
|
|
|
@ -81,11 +81,11 @@ pub(crate) fn clean_middle_generic_args<'tcx>(
|
|||
args: ty::Binder<'tcx, &'tcx [ty::GenericArg<'tcx>]>,
|
||||
mut has_self: bool,
|
||||
owner: DefId,
|
||||
) -> Vec<GenericArg> {
|
||||
) -> ThinVec<GenericArg> {
|
||||
let (args, bound_vars) = (args.skip_binder(), args.bound_vars());
|
||||
if args.is_empty() {
|
||||
// Fast path which avoids executing the query `generics_of`.
|
||||
return Vec::new();
|
||||
return ThinVec::new();
|
||||
}
|
||||
|
||||
// If the container is a trait object type, the arguments won't contain the self type but the
|
||||
|
@ -144,7 +144,7 @@ pub(crate) fn clean_middle_generic_args<'tcx>(
|
|||
};
|
||||
|
||||
let offset = if has_self { 1 } else { 0 };
|
||||
let mut clean_args = Vec::with_capacity(args.len().saturating_sub(offset));
|
||||
let mut clean_args = ThinVec::with_capacity(args.len().saturating_sub(offset));
|
||||
clean_args.extend(args.iter().enumerate().rev().filter_map(clean_arg));
|
||||
clean_args.reverse();
|
||||
clean_args
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue