Rollup merge of #55755 - ljedrz:a_few_indexvec_tweaks, r=varkor
Improve creation of 3 IndexVecs - preallocate when the minimal size is known - use `from_elem_n` instead of `new`+`resize`
This commit is contained in:
commit
660340e4aa
2 changed files with 4 additions and 4 deletions
|
@ -450,8 +450,7 @@ impl<'sess> OnDiskCache<'sess> {
|
||||||
.map(|&(cnum, ..)| cnum)
|
.map(|&(cnum, ..)| cnum)
|
||||||
.max()
|
.max()
|
||||||
.unwrap_or(0) + 1;
|
.unwrap_or(0) + 1;
|
||||||
let mut map = IndexVec::new();
|
let mut map = IndexVec::from_elem_n(None, map_size as usize);
|
||||||
map.resize(map_size as usize, None);
|
|
||||||
|
|
||||||
for &(prev_cnum, ref crate_name, crate_disambiguator) in prev_cnums {
|
for &(prev_cnum, ref crate_name, crate_disambiguator) in prev_cnums {
|
||||||
let key = (crate_name.clone(), crate_disambiguator);
|
let key = (crate_name.clone(), crate_disambiguator);
|
||||||
|
|
|
@ -196,7 +196,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
let source_info = SourceInfo { span, scope: OUTERMOST_SOURCE_SCOPE };
|
let source_info = SourceInfo { span, scope: OUTERMOST_SOURCE_SCOPE };
|
||||||
|
|
||||||
let return_block = BasicBlock::new(1);
|
let return_block = BasicBlock::new(1);
|
||||||
let mut blocks = IndexVec::new();
|
let mut blocks = IndexVec::with_capacity(2);
|
||||||
let block = |blocks: &mut IndexVec<_, _>, kind| {
|
let block = |blocks: &mut IndexVec<_, _>, kind| {
|
||||||
blocks.push(BasicBlockData {
|
blocks.push(BasicBlockData {
|
||||||
statements: vec![],
|
statements: vec![],
|
||||||
|
@ -768,7 +768,8 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut blocks = IndexVec::new();
|
let n_blocks = if let Adjustment::RefMut = rcvr_adjustment { 5 } else { 2 };
|
||||||
|
let mut blocks = IndexVec::with_capacity(n_blocks);
|
||||||
let block = |blocks: &mut IndexVec<_, _>, statements, kind, is_cleanup| {
|
let block = |blocks: &mut IndexVec<_, _>, statements, kind, is_cleanup| {
|
||||||
blocks.push(BasicBlockData {
|
blocks.push(BasicBlockData {
|
||||||
statements,
|
statements,
|
||||||
|
|
Loading…
Add table
Reference in a new issue