Skip to content

Commit e5aeba7

Browse files
committed
Simplify apply_static_swaps formatting and logic
Inline next_swappable params and replace manual conflict loop with Iterator::any.
1 parent 3b71dc4 commit e5aeba7

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

‎crates/codegen/src/ir.rs‎

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,11 +1405,7 @@ impl CodeInfo {
14051405
/// Next swappable index after `i` in `instrs`, skipping NOPs.
14061406
/// Returns None if a non-NOP non-swappable instruction blocks, or
14071407
/// if `lineno >= 0` and a different lineno is encountered.
1408-
fn next_swappable(
1409-
instrs: &[InstructionInfo],
1410-
mut i: usize,
1411-
lineno: i32,
1412-
) -> Option<usize> {
1408+
fn next_swappable(instrs: &[InstructionInfo], mut i: usize, lineno: i32) -> Option<usize> {
14131409
loop {
14141410
i += 1;
14151411
if i >= instrs.len() {
@@ -1482,15 +1478,13 @@ impl CodeInfo {
14821478
i += 1;
14831479
continue;
14841480
}
1485-
let mut conflict = false;
1486-
for idx in (j + 1)..k {
1487-
if let Some(store_idx) = stores_to(&instrs[idx])
1488-
&& (Some(store_idx) == store_j || Some(store_idx) == store_k)
1489-
{
1490-
conflict = true;
1491-
break;
1481+
let conflict = instrs[(j + 1)..k].iter().any(|info| {
1482+
if let Some(store_idx) = stores_to(info) {
1483+
Some(store_idx) == store_j || Some(store_idx) == store_k
1484+
} else {
1485+
false
14921486
}
1493-
}
1487+
});
14941488
if conflict {
14951489
i += 1;
14961490
continue;

0 commit comments

Comments
 (0)