]> Repositorios git - scryer-prolog.git/commitdiff
do not traverse data structures when binding to local variables in unify_with_occurs_...
authorMark Thom <[email protected]>
Wed, 3 Feb 2021 18:11:22 +0000 (11:11 -0700)
committerMark Thom <[email protected]>
Wed, 3 Feb 2021 18:11:22 +0000 (11:11 -0700)
src/machine/machine_state_impl.rs

index 5de0714011dd7f2eec4a81ef9a8e1238db2ef27a..f7cda917d1a94ae0658f964c2d8edc5cc3d4d490 100644 (file)
@@ -201,6 +201,14 @@ impl MachineState {
     }
 
     fn bind_with_occurs_check(&mut self, r: Ref, addr: Addr) {
+        if let Ref::StackCell(..) = r {
+            // local variable optimization -- r cannot occur in the
+            // data structure bound to addr, so don't bother
+            // traversing it.
+            self.bind(r, addr);
+            return;
+        }
+
         let mut fail = false;
 
         for addr in self.acyclic_pre_order_iter(addr) {