correct LIS backward bug in cycle_detection.rs
This commit is contained in:
@@ -105,18 +105,16 @@ impl<'a, const STOP_AT_CYCLES: bool> CycleDetectingIter<'a, STOP_AT_CYCLES> {
|
|||||||
let next = self.next as usize;
|
let next = self.next as usize;
|
||||||
|
|
||||||
if self.heap[next].get_forwarding_bit() {
|
if self.heap[next].get_forwarding_bit() {
|
||||||
if self.current != next {
|
return if self.current != next {
|
||||||
return if self.cycle_detection_active() {
|
if self.cycle_detection_active() {
|
||||||
self.cycle_found = true;
|
self.cycle_found = true;
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(self.backward_and_return())
|
Some(self.backward_and_return())
|
||||||
};
|
|
||||||
} else if self.backward() {
|
|
||||||
return None;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
continue;
|
Some(self.backward_and_return())
|
||||||
|
};
|
||||||
} else if self.heap[next].get_mark_bit() == self.mark_phase {
|
} else if self.heap[next].get_mark_bit() == self.mark_phase {
|
||||||
return Some(self.backward_and_return());
|
return Some(self.backward_and_return());
|
||||||
}
|
}
|
||||||
@@ -130,11 +128,9 @@ impl<'a, const STOP_AT_CYCLES: bool> CycleDetectingIter<'a, STOP_AT_CYCLES> {
|
|||||||
self.next = temp;
|
self.next = temp;
|
||||||
|
|
||||||
if self.next < self.heap.len() as u64 {
|
if self.next < self.heap.len() as u64 {
|
||||||
if self.heap[self.next as usize].get_mark_bit() == self.mark_phase {
|
|
||||||
return Some(HeapCellValue::build_with(tag, next as u64));
|
return Some(HeapCellValue::build_with(tag, next as u64));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
HeapCellValueTag::Str => {
|
HeapCellValueTag::Str => {
|
||||||
let h = self.next as usize;
|
let h = self.next as usize;
|
||||||
let cell = self.heap[h];
|
let cell = self.heap[h];
|
||||||
@@ -350,8 +346,8 @@ impl<'a, const STOP_AT_CYCLES: bool> CycleDetectingIter<'a, STOP_AT_CYCLES> {
|
|||||||
self.heap[self.current].set_mark_bit(self.mark_phase);
|
self.heap[self.current].set_mark_bit(self.mark_phase);
|
||||||
|
|
||||||
if self.heap[self.current - 1].get_forwarding_bit() {
|
if self.heap[self.current - 1].get_forwarding_bit() {
|
||||||
self.next = self.current as u64 - 1;
|
|
||||||
self.heap[self.current].set_value(self.next);
|
self.heap[self.current].set_value(self.next);
|
||||||
|
self.next = self.current as u64 - 1;
|
||||||
self.current = temp as usize;
|
self.current = temp as usize;
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|||||||
Reference in New Issue
Block a user