Skip to content

Commit f27ba3c

Browse files
committed
coverage: Store a BCB's list of basic blocks as a boxed slice
1 parent bf4ee59 commit f27ba3c

File tree

1 file changed

+5
-5
lines changed
  • compiler/rustc_mir_transform/src/coverage

1 file changed

+5
-5
lines changed

compiler/rustc_mir_transform/src/coverage/graph.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ impl CoverageGraph {
8585
let mut bb_to_bcb = IndexVec::from_elem_n(None, num_basic_blocks);
8686

8787
let mut add_basic_coverage_block = |basic_blocks: &mut Vec<BasicBlock>| {
88-
// Take the accumulated list of blocks, but leave
88+
// Take the accumulated list of blocks as a boxed slice, but leave
8989
// the vector's capacity intact to be reused for subsequent BCBs.
90-
let basic_blocks = basic_blocks.split_off(0);
90+
let basic_blocks: Box<[BasicBlock]> = basic_blocks.split_off(0).into();
9191

9292
let bcb = bcbs.next_index();
9393
for &bb in basic_blocks.iter() {
9494
bb_to_bcb[bb] = Some(bcb);
9595
}
96-
let bcb_data = BasicCoverageBlockData::from(basic_blocks);
96+
let bcb_data = BasicCoverageBlockData::new(basic_blocks);
9797
debug!("adding bcb{}: {:?}", bcb.index(), bcb_data);
9898
bcbs.push(bcb_data);
9999
};
@@ -281,11 +281,11 @@ rustc_index::newtype_index! {
281281
/// significance.
282282
#[derive(Debug, Clone)]
283283
pub(super) struct BasicCoverageBlockData {
284-
pub basic_blocks: Vec<BasicBlock>,
284+
pub basic_blocks: Box<[BasicBlock]>,
285285
}
286286

287287
impl BasicCoverageBlockData {
288-
pub fn from(basic_blocks: Vec<BasicBlock>) -> Self {
288+
pub fn new(basic_blocks: Box<[BasicBlock]>) -> Self {
289289
assert!(basic_blocks.len() > 0);
290290
Self { basic_blocks }
291291
}

0 commit comments

Comments
 (0)