Reserve space in advance
This commit is contained in:
parent
2ca0b85593
commit
a7f2bb6343
|
@ -221,7 +221,7 @@ impl TokenStream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some((pos, comma, sp)) = suggestion {
|
if let Some((pos, comma, sp)) = suggestion {
|
||||||
let mut new_stream = vec![];
|
let mut new_stream = Vec::with_capacity(self.0.len() + 1);
|
||||||
let parts = self.0.split_at(pos + 1);
|
let parts = self.0.split_at(pos + 1);
|
||||||
new_stream.extend_from_slice(parts.0);
|
new_stream.extend_from_slice(parts.0);
|
||||||
new_stream.push(comma);
|
new_stream.push(comma);
|
||||||
|
|
|
@ -2011,17 +2011,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
//
|
//
|
||||||
// For the "output" lifetime parameters, we just want to
|
// For the "output" lifetime parameters, we just want to
|
||||||
// generate `'_`.
|
// generate `'_`.
|
||||||
let mut generic_args: Vec<_> = lifetime_params[..input_lifetimes_count]
|
let mut generic_args = Vec::with_capacity(lifetime_params.len());
|
||||||
.iter()
|
generic_args.extend(lifetime_params[..input_lifetimes_count].iter().map(
|
||||||
.map(|&(span, hir_name)| {
|
|&(span, hir_name)| {
|
||||||
// Input lifetime like `'a` or `'1`:
|
// Input lifetime like `'a` or `'1`:
|
||||||
GenericArg::Lifetime(hir::Lifetime {
|
GenericArg::Lifetime(hir::Lifetime {
|
||||||
hir_id: self.next_id(),
|
hir_id: self.next_id(),
|
||||||
span,
|
span,
|
||||||
name: hir::LifetimeName::Param(hir_name),
|
name: hir::LifetimeName::Param(hir_name),
|
||||||
})
|
})
|
||||||
})
|
},
|
||||||
.collect();
|
));
|
||||||
generic_args.extend(lifetime_params[input_lifetimes_count..].iter().map(|&(span, _)|
|
generic_args.extend(lifetime_params[input_lifetimes_count..].iter().map(|&(span, _)|
|
||||||
// Output lifetime like `'_`.
|
// Output lifetime like `'_`.
|
||||||
GenericArg::Lifetime(hir::Lifetime {
|
GenericArg::Lifetime(hir::Lifetime {
|
||||||
|
|
|
@ -66,7 +66,7 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>
|
||||||
|
|
||||||
let fmt = substr.nonself_args[0].clone();
|
let fmt = substr.nonself_args[0].clone();
|
||||||
|
|
||||||
let mut stmts = vec![];
|
let mut stmts = Vec::with_capacity(fields.len() + 2);
|
||||||
match vdata {
|
match vdata {
|
||||||
ast::VariantData::Tuple(..) | ast::VariantData::Unit(..) => {
|
ast::VariantData::Tuple(..) | ast::VariantData::Unit(..) => {
|
||||||
// tuple struct/"normal" variant
|
// tuple struct/"normal" variant
|
||||||
|
|
|
@ -30,6 +30,8 @@ fn lint_levels(tcx: TyCtxt<'_>, cnum: CrateNum) -> LintLevelMap {
|
||||||
let mut builder = LintLevelMapBuilder { levels, tcx, store };
|
let mut builder = LintLevelMapBuilder { levels, tcx, store };
|
||||||
let krate = tcx.hir().krate();
|
let krate = tcx.hir().krate();
|
||||||
|
|
||||||
|
builder.levels.id_to_set.reserve(krate.exported_macros.len() + 1);
|
||||||
|
|
||||||
let push = builder.levels.push(&krate.item.attrs, &store, true);
|
let push = builder.levels.push(&krate.item.attrs, &store, true);
|
||||||
builder.levels.register_id(hir::CRATE_HIR_ID);
|
builder.levels.register_id(hir::CRATE_HIR_ID);
|
||||||
for macro_def in krate.exported_macros {
|
for macro_def in krate.exported_macros {
|
||||||
|
|
Loading…
Reference in New Issue