Skip to content

Commit 153ab6b

Browse files
committed
ZJIT: Simplify guard dedup with Iterator::find
1 parent 48dd4b1 commit 153ab6b

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

zjit/src/hir.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5255,14 +5255,9 @@ impl Function {
52555255
// e.g. if we already proved val is Fixnum, a later Fixnum or
52565256
// BasicObject guard on the same val is guaranteed to pass.
52575257
Insn::GuardType { val, guard_type, .. } => {
5258-
let mut found = None;
5259-
for &(prev_val, prev_type, prev_result) in &seen_guards {
5260-
if prev_val == val && prev_type.is_subtype(guard_type) {
5261-
found = Some(prev_result);
5262-
break;
5263-
}
5264-
}
5265-
if let Some(prev_result) = found {
5258+
if let Some(&(_, _, prev_result)) = seen_guards.iter().find(
5259+
|&&(prev_val, prev_type, _)| prev_val == val && prev_type.is_subtype(guard_type)
5260+
) {
52665261
self.make_equal_to(insn_id, prev_result);
52675262
continue;
52685263
}

0 commit comments

Comments
 (0)