fix match/if-let can be simplified to ?

This commit is contained in:
Bennet Bleßmann
2025-07-31 21:34:15 +02:00
committed by Bennet Bleßmann
parent 495bcd73f2
commit a639fec153
2 changed files with 3 additions and 11 deletions

View File

@@ -137,10 +137,7 @@ impl<'a, const STOP_AT_CYCLES: bool> CycleDetectingIter<'a, STOP_AT_CYCLES> {
let cell = self.heap[h]; let cell = self.heap[h];
let arity = cell_as_atom_cell!(self.heap[h]).get_arity(); let arity = cell_as_atom_cell!(self.heap[h]).get_arity();
let last_cell_loc = match self.traverse_subterm(h + 1, arity) { let last_cell_loc = self.traverse_subterm(h + 1, arity)?;
Some(last_cell_loc) => last_cell_loc,
None => return None,
};
if last_cell_loc == h { if last_cell_loc == h {
if self.backward() { if self.backward() {
@@ -171,10 +168,7 @@ impl<'a, const STOP_AT_CYCLES: bool> CycleDetectingIter<'a, STOP_AT_CYCLES> {
let mut cell = self.heap[self.current]; let mut cell = self.heap[self.current];
cell.set_value(self.next); cell.set_value(self.next);
let last_cell_loc = match self.traverse_subterm(self.next as usize, 2) { let last_cell_loc = self.traverse_subterm(self.next as usize, 2)?;
Some(last_cell_loc) => last_cell_loc,
None => return None,
};
if self.cycle_detection_active() { if self.cycle_detection_active() {
for idx in (self.next as usize..last_cell_loc).rev() { for idx in (self.next as usize..last_cell_loc).rev() {

View File

@@ -4152,9 +4152,7 @@ impl Machine {
let mut functor_writer = Heap::functor_writer(functor); let mut functor_writer = Heap::functor_writer(functor);
if let Err(e) = functor_writer(heap) { functor_writer(heap)?;
return Err(e);
}
num_functors += 1; num_functors += 1;
} }