check that lower bound on term expansion drain is below the len of the term expansion vector, queue (#416)

This commit is contained in:
Mark Thom
2020-04-28 19:22:20 -06:00
parent 0e1226573a
commit a3bb288f01
2 changed files with 17 additions and 5 deletions

View File

@@ -53,12 +53,23 @@ impl CodeRepo {
self.term_dir
.get_mut(&key)
.map(|entry| {
(
Predicate((entry.0).0.drain(len..).collect()),
entry.1.drain(queue_len..).collect(),
)
let terms =
if len < (entry.0).0.len() {
(entry.0).0.drain(len ..).collect()
} else {
vec![]
};
let queue =
if queue_len < entry.1.len() {
entry.1.drain(queue_len ..).collect()
} else {
VecDeque::new()
};
(Predicate(terms), queue)
})
.unwrap_or((Predicate::new(), VecDeque::from(vec![])))
.unwrap_or((Predicate::new(), VecDeque::new()))
}
pub(crate)

View File

@@ -181,6 +181,7 @@ impl<'a> TermStream<'a> {
te_len,
te_queue_len,
);
let goal_expansion_additions = self.wam.code_repo.truncate_terms(
(clause_name!("goal_expansion"), 2),
ge_len,