Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/librustc/middle/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ fn build_local_id_to_index(body: Option<&hir::Body>,

cfg.graph.each_node(|node_idx, node| {
if let cfg::CFGNodeData::AST(id) = node.data {
index.entry(id).or_insert(vec![]).push(node_idx);
index.entry(id).or_insert_with(|| Vec::with_capacity(1)).push(node_idx);
}
true
});
Expand Down Expand Up @@ -209,7 +209,8 @@ fn build_local_id_to_index(body: Option<&hir::Body>,
}

fn visit_pat(&mut self, p: &hir::Pat) {
self.index.entry(p.hir_id.local_id).or_insert(vec![]).push(self.entry);
self.index.entry(p.hir_id.local_id)
.or_insert_with(|| Vec::with_capacity(1)).push(self.entry);
intravisit::walk_pat(self, p)
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/librustc/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,11 @@ fn opt_normalize_projection_type<'a, 'b, 'gcx, 'tcx>(
// can ignore the `obligations` from that point on.
if !infcx.any_unresolved_type_vars(&ty.value) {
infcx.projection_cache.borrow_mut().complete(cache_key);
ty.obligations = vec![];
// Use with_capacity(1) because
// push_paranoid_cache_value_obligation() will push one
// element, and then usually no more elements are pushed.
// (Vec::new() + push() gives a capacity of 4.)
ty.obligations = Vec::with_capacity(1);
}

push_paranoid_cache_value_obligation(infcx,
Expand Down