Skip to content

Commit 3814ec5

Browse files
committed
Collect directly into ThinVec
1 parent e90f129 commit 3814ec5

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

Diff for: src/librustdoc/clean/mod.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,7 @@ fn projection_to_path_segment<'tcx>(
516516
ty.map_bound(|ty| &ty.args[generics.parent_count..]),
517517
false,
518518
def_id,
519-
)
520-
.into(),
519+
),
521520
constraints: Default::default(),
522521
},
523522
}
@@ -2202,8 +2201,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
22022201
alias_ty.map_bound(|ty| ty.args.as_slice()),
22032202
true,
22042203
def_id,
2205-
)
2206-
.into(),
2204+
),
22072205
constraints: Default::default(),
22082206
},
22092207
},
@@ -2521,7 +2519,7 @@ fn clean_generic_args<'tcx>(
25212519
) -> GenericArgs {
25222520
// FIXME(return_type_notation): Fix RTN parens rendering
25232521
if let Some((inputs, output)) = generic_args.paren_sugar_inputs_output() {
2524-
let inputs = inputs.iter().map(|x| clean_ty(x, cx)).collect::<Vec<_>>().into();
2522+
let inputs = inputs.iter().map(|x| clean_ty(x, cx)).collect::<ThinVec<_>>().into();
25252523
let output = match output.kind {
25262524
hir::TyKind::Tup(&[]) => None,
25272525
_ => Some(Box::new(clean_ty(output, cx))),
@@ -2542,7 +2540,7 @@ fn clean_generic_args<'tcx>(
25422540
}
25432541
hir::GenericArg::Infer(_inf) => GenericArg::Infer,
25442542
})
2545-
.collect::<Vec<_>>()
2543+
.collect::<ThinVec<_>>()
25462544
.into();
25472545
let constraints = generic_args
25482546
.constraints

Diff for: src/librustdoc/clean/utils.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ pub(crate) fn clean_middle_generic_args<'tcx>(
8181
args: ty::Binder<'tcx, &'tcx [ty::GenericArg<'tcx>]>,
8282
mut has_self: bool,
8383
owner: DefId,
84-
) -> Vec<GenericArg> {
84+
) -> ThinVec<GenericArg> {
8585
let (args, bound_vars) = (args.skip_binder(), args.bound_vars());
8686
if args.is_empty() {
8787
// Fast path which avoids executing the query `generics_of`.
88-
return Vec::new();
88+
return ThinVec::new();
8989
}
9090

9191
// 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>(
144144
};
145145

146146
let offset = if has_self { 1 } else { 0 };
147-
let mut clean_args = Vec::with_capacity(args.len().saturating_sub(offset));
147+
let mut clean_args = ThinVec::with_capacity(args.len().saturating_sub(offset));
148148
clean_args.extend(args.iter().enumerate().rev().filter_map(clean_arg));
149149
clean_args.reverse();
150150
clean_args

0 commit comments

Comments
 (0)