Skip to content

Commit 4db90b2

Browse files
committed
remove some idx() calls
1 parent 7564087 commit 4db90b2

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

‎crates/codegen/src/ir.rs‎

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6118,7 +6118,7 @@ fn cfg_builder_check_size(g: &CfgBuilder) -> crate::InternalResult<()> {
61186118
while block != BlockIdx::NULL {
61196119
debug_assert!(block.idx() < g.blocks.len());
61206120
nblocks += 1;
6121-
block = g.blocks[block.idx()].allocation_next;
6121+
block = g.blocks[block].allocation_next;
61226122
}
61236123
debug_assert_eq!(nblocks, g.blocks.len());
61246124
if nblocks > usize::MAX / core::mem::size_of::<usize>() {
@@ -6258,13 +6258,12 @@ fn maybe_push(
62586258
) {
62596259
debug_assert!(block != BlockIdx::NULL);
62606260

6261-
let idx = block.idx();
6262-
let both = blocks[idx].unsafe_locals_mask | unsafe_mask;
6263-
if blocks[idx].unsafe_locals_mask != both {
6264-
blocks[idx].unsafe_locals_mask = both;
6265-
if !blocks[idx].visited {
6261+
let both = blocks[block].unsafe_locals_mask | unsafe_mask;
6262+
if blocks[block].unsafe_locals_mask != both {
6263+
blocks[block].unsafe_locals_mask = both;
6264+
if !blocks[block].visited {
62666265
worklist.push(block);
6267-
blocks[idx].visited = true;
6266+
blocks[block].visited = true;
62686267
}
62696268
}
62706269
}
@@ -6351,8 +6350,8 @@ fn fast_scan_many_locals(blocks: &mut Blocks, nlocals: usize) -> crate::Internal
63516350
let mut current = BlockIdx(0);
63526351
while current != BlockIdx::NULL {
63536352
blocknum += 1;
6354-
for i in 0..blocks[current.idx()].instruction_used {
6355-
let info = &mut blocks[current.idx()].instructions[i];
6353+
for i in 0..blocks[current].instruction_used {
6354+
let info = &mut blocks[current].instructions[i];
63566355
debug_assert!(!matches!(info.instr.real(), Some(Instruction::ExtendedArg)));
63576356
let arg = u32::from(info.arg) as usize;
63586357
if arg < LOCAL_UNSAFE_MASK_BITS {
@@ -6381,7 +6380,7 @@ fn fast_scan_many_locals(blocks: &mut Blocks, nlocals: usize) -> crate::Internal
63816380
_ => {}
63826381
}
63836382
}
6384-
current = blocks[current.idx()].next;
6383+
current = blocks[current].next;
63856384
}
63866385
Ok(())
63876386
}
@@ -6411,11 +6410,11 @@ fn add_checks_for_loads_of_uninitialized_variables(
64116410
let mut current = BlockIdx(0);
64126411
while current != BlockIdx::NULL {
64136412
scan_block_for_locals(blocks, current, &mut worklist);
6414-
current = blocks[current.idx()].next;
6413+
current = blocks[current].next;
64156414
}
64166415

64176416
while let Some(block_idx) = worklist.pop() {
6418-
blocks[block_idx.idx()].visited = false;
6417+
blocks[block_idx].visited = false;
64196418
scan_block_for_locals(blocks, block_idx, &mut worklist);
64206419
}
64216420
Ok(())
@@ -6527,9 +6526,9 @@ fn get_max_label(blocks: &Blocks) -> i32 {
65276526
let mut lbl = -1;
65286527
let mut current = BlockIdx(0);
65296528
while current != BlockIdx::NULL {
6530-
let cpython_label = blocks[current.idx()].cpython_label;
6529+
let cpython_label = blocks[current].cpython_label;
65316530
lbl = lbl.max(cpython_label.0);
6532-
current = blocks[current.idx()].next;
6531+
current = blocks[current].next;
65336532
}
65346533
lbl
65356534
}
@@ -6708,8 +6707,8 @@ pub(crate) fn label_exception_targets(blocks: &mut Blocks) -> crate::InternalRes
67086707
pub(crate) fn convert_pseudo_ops(blocks: &mut Blocks) -> crate::InternalResult<()> {
67096708
let mut block_idx = BlockIdx(0);
67106709
while block_idx != BlockIdx::NULL {
6711-
let next = blocks[block_idx.idx()].next;
6712-
let block = &mut blocks[block_idx.idx()];
6710+
let next = blocks[block_idx].next;
6711+
let block = &mut blocks[block_idx];
67136712
for i in 0..block.instruction_used {
67146713
let info = &mut block.instructions[i];
67156714
if is_block_push(info) {

0 commit comments

Comments
 (0)