]> Repositorios git - scryer-prolog.git/commitdiff
stop detecting cycles in compare_pstr_to_string
authorMark Thom <[email protected]>
Mon, 11 Apr 2022 01:46:34 +0000 (19:46 -0600)
committerMark Thom <[email protected]>
Mon, 11 Apr 2022 01:46:34 +0000 (19:46 -0600)
src/machine/partial_string.rs

index 7cf96c7d3260891a411b5136ec9d7215b5995126..b4b3714ab089196ce3f9d92b803aa71c47be538e 100644 (file)
@@ -109,6 +109,12 @@ impl<'a> HeapPStrIter<'a> {
         self.brent_st.num_steps()
     }
 
+    #[inline]
+    pub fn chars(mut self) -> PStrCharsIter<'a> {
+        let item = self.next();
+        PStrCharsIter { iter: self, item }
+    }
+
     pub fn compare_pstr_to_string(&mut self, s: &str) -> Option<PStrPrefixCmpResult> {
         let mut result = PStrPrefixCmpResult {
             focus: self.brent_st.hare,
@@ -116,7 +122,10 @@ impl<'a> HeapPStrIter<'a> {
             prefix_len: 0,
         };
 
-        while let Some(iteratee) = self.next() {
+        while let Some(PStrIterStep { iteratee, next_hare }) = self.step(self.brent_st.hare) {
+            self.brent_st.hare = next_hare;
+            self.focus = self.heap[next_hare];
+
             result.focus  = iteratee.focus();
             result.offset = iteratee.offset();
 
@@ -164,12 +173,6 @@ impl<'a> HeapPStrIter<'a> {
         Some(result)
     }
 
-    #[inline]
-    pub fn chars(mut self) -> PStrCharsIter<'a> {
-        let item = self.next();
-        PStrCharsIter { iter: self, item }
-    }
-
     fn walk_hare_to_cycle_end(&mut self) {
         // walk_hare_to_cycle_end assumes a cycle has been found,
         // so it is always safe to unwrap self.step()