use crate::read::TermWriteResult;
use crate::types::*;
+use fxhash::FxBuildHasher;
use indexmap::IndexMap;
+use indexmap::IndexSet;
use std::convert::TryFrom;
use std::fmt;
pub atom_tbl: Arc<AtomTable>,
pub arena: Arena,
pub(super) pdl: Vec<(HeapCellValue, HeapCellValue)>,
+ pub(super) unify_tabu_list: IndexSet<(HeapCellValue, HeapCellValue), FxBuildHasher>,
pub(super) s: HeapPtr,
pub(super) s_offset: usize,
pub(super) p: usize,
+use fxhash::FxBuildHasher;
+use indexmap::IndexSet;
+
use crate::arena::*;
use crate::atom_table::*;
use crate::forms::*;
arena: Arena::new().unwrap(),
atom_tbl: AtomTable::new().unwrap(),
pdl: Vec::with_capacity(1024),
+ unify_tabu_list: IndexSet::with_hasher(FxBuildHasher::default()),
s: HeapPtr::default(),
s_offset: 0,
p: 0,
use std::ops::{Deref, DerefMut};
use derive_more::*;
-use fxhash::FxBuildHasher;
-use indexmap::IndexSet;
use num_order::NumOrd;
impl MachineState {
}
fn unify_internal(&mut self) {
- let mut tabu_list = IndexSet::with_hasher(FxBuildHasher::default());
+ debug_assert!(self.unify_tabu_list.is_empty());
while let Some((s1, s2)) = self.pdl.pop() {
if self.fail {
Self::unify_atom(self, name, d2);
}
(HeapCellValueTag::Str, s1) => {
- if tabu_list.contains(&(d1, d2)) {
+ if self.unify_tabu_list.contains(&(d1, d2)) {
continue;
}
if !self.fail {
let d2 = self.store(d2);
- tabu_list.insert((d1, d2));
+ self.unify_tabu_list.insert((d1, d2));
}
}
(HeapCellValueTag::Lis, l1) => {
- if d2.is_ref() && tabu_list.contains(&(d1, d2)) {
+ if d2.is_ref() && self.unify_tabu_list.contains(&(d1, d2)) {
continue;
}
if !self.fail {
let d2 = self.store(d2);
- tabu_list.insert((d1, d2));
+ self.unify_tabu_list.insert((d1, d2));
}
}
(HeapCellValueTag::PStrLoc, l) => {
(HeapCellValueTag::PStrLoc |
HeapCellValueTag::Lis |
HeapCellValueTag::Str) => {
- if tabu_list.contains(&(d1, d2)) {
+ if self.unify_tabu_list.contains(&(d1, d2)) {
continue;
}
}
if !self.fail && !d2.is_constant() {
let d2 = self.store(d2);
- tabu_list.insert((d1, d2));
+ self.unify_tabu_list.insert((d1, d2));
}
}
(HeapCellValueTag::F64Offset, f1) => {
);
}
}
+
+ self.unify_tabu_list.clear();
}
fn bind(&mut self, r: Ref, value: HeapCellValue);