Skip to content

Commit

Permalink
syntax: improve a few allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
ljedrz committed Oct 31, 2018
1 parent 0db7abe commit f4c03fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 && ...
Expand Down

0 comments on commit f4c03fd

Please sign in to comment.