Rollup merge of #55542 - ljedrz:syntax_alloc_improvements, r=kennytm
syntax: improve a few allocations Add 2 `reserve`s and a `with_capacity` where the final vector size is known.
This commit is contained in:
commit
133ba2d063
2 changed files with 3 additions and 1 deletions
|
|
@ -387,6 +387,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||
add_derived_markers(&mut self.cx, item.span(), &traits, item.clone());
|
||||
let derives = derives.entry(invoc.expansion_data.mark).or_default();
|
||||
|
||||
derives.reserve(traits.len());
|
||||
invocations.reserve(traits.len());
|
||||
for path in &traits {
|
||||
let mark = Mark::fresh(self.cx.current_expansion.mark);
|
||||
derives.push(mark);
|
||||
|
|
|
|||
|
|
@ -1384,7 +1384,7 @@ impl<'a> MethodDef<'a> {
|
|||
// let __self2_vi = unsafe {
|
||||
// std::intrinsics::discriminant_value(&arg2) } as i32;
|
||||
// ```
|
||||
let mut index_let_stmts: Vec<ast::Stmt> = Vec::new();
|
||||
let mut index_let_stmts: Vec<ast::Stmt> = Vec::with_capacity(vi_idents.len() + 1);
|
||||
|
||||
// We also build an expression which checks whether all discriminants are equal
|
||||
// discriminant_test = __self0_vi == __self1_vi && __self0_vi == __self2_vi && ...
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue