mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-17 05:25:37 +03:00
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:
@@ -387,6 +387,8 @@ fn expand_fragment(&mut self, input_fragment: AstFragment) -> AstFragment {
|
||||
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 @@ fn build_enum_match_tuple<'b>(&self,
|
||||
// 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 && ...
|
||||
|
||||
Reference in New Issue
Block a user