Skip to content

Commit 264e06e

Browse files
committed
Pre-allocate places vectors.
1 parent 76e04c0 commit 264e06e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler/rustc_mir_dataflow/src/value_analysis.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,13 @@ impl<'tcx> Map<'tcx> {
364364
/// chosen is an implementation detail and may not be relied upon (other than that their type
365365
/// are scalars).
366366
pub fn new(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, value_limit: Option<usize>) -> Self {
367+
let capacity = 4 * body.local_decls.len() + value_limit.unwrap_or(body.local_decls.len());
367368
let mut map = Self {
368369
locals: IndexVec::from_elem(None, &body.local_decls),
369370
projections: FxHashMap::default(),
370-
places: IndexVec::new(),
371+
places: IndexVec::with_capacity(capacity),
371372
value_count: 0,
372-
inner_values: IndexVec::new(),
373+
inner_values: IndexVec::with_capacity(capacity),
373374
inner_values_buffer: Vec::new(),
374375
};
375376
map.register_locals(tcx, body);

0 commit comments

Comments
 (0)