]> Repositorios git - scryer-prolog.git/commitdiff
fix match/if-let can be simplified to ?
authorBennet Bleßmann <[email protected]>
Thu, 31 Jul 2025 19:34:15 +0000 (21:34 +0200)
committerBennet Bleßmann <[email protected]>
Thu, 31 Jul 2025 19:47:03 +0000 (21:47 +0200)
src/machine/cycle_detection.rs
src/machine/system_calls.rs

index da125518ea1e75e9b196f3d5f2acebd1d80c7745..a800a9b6c6db80046ef50929ad0c1cd23e94793f 100644 (file)
@@ -137,10 +137,7 @@ impl<'a, const STOP_AT_CYCLES: bool> CycleDetectingIter<'a, STOP_AT_CYCLES> {
                         let cell = self.heap[h];
                         let arity = cell_as_atom_cell!(self.heap[h]).get_arity();
 
-                        let last_cell_loc = match self.traverse_subterm(h + 1, arity) {
-                            Some(last_cell_loc) => last_cell_loc,
-                            None => return None,
-                        };
+                        let last_cell_loc = self.traverse_subterm(h + 1, arity)?;
 
                         if last_cell_loc == h {
                             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];
                         cell.set_value(self.next);
 
-                        let last_cell_loc = match self.traverse_subterm(self.next as usize, 2) {
-                            Some(last_cell_loc) => last_cell_loc,
-                            None => return None,
-                        };
+                        let last_cell_loc = self.traverse_subterm(self.next as usize, 2)?;
 
                         if self.cycle_detection_active() {
                             for idx in (self.next as usize..last_cell_loc).rev() {
index ac09b7f81f17d163cc9d22706b3ec550d2fa620d..10323c5c44a8516fd767ee05ff822b1c764dc2a3 100644 (file)
@@ -4152,9 +4152,7 @@ impl Machine {
 
                 let mut functor_writer = Heap::functor_writer(functor);
 
-                if let Err(e) = functor_writer(heap) {
-                    return Err(e);
-                }
+                functor_writer(heap)?;
 
                 num_functors += 1;
             }