eliminate duplicates in term_variables/2, term_attributed_variables/2 (#481)

This commit is contained in:
Mark Thom
2020-05-10 13:43:39 -06:00
parent ea7b1a9592
commit c5057127ee
2 changed files with 14 additions and 1 deletions

View File

@@ -18,6 +18,8 @@ use crate::prolog::ordered_float::OrderedFloat;
use crate::prolog::read::readline;
use crate::prolog::rug::Integer;
use crate::indexmap::IndexSet;
use crate::ref_thread_local::RefThreadLocal;
use std::cmp;
@@ -4838,11 +4840,13 @@ impl MachineState {
}
&SystemClauseType::TermVariables => {
let a1 = self[temp_v!(1)];
let mut seen_set = IndexSet::new();
let mut seen_vars = vec![];
for addr in self.acyclic_pre_order_iter(a1) {
if addr.is_ref() {
if addr.is_ref() && !seen_set.contains(&addr) {
seen_vars.push(addr);
seen_set.insert(addr);
}
}