Skip to content

Commit b748393

Browse files
Refactor Engine's watch propagation logic for improved readability and efficiency
1 parent b4bd6e2 commit b748393

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/lib.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,11 @@ impl Engine {
274274
let watches = if self.value(var) == &LBool::True { mem::take(&mut self.neg_watches[var]) } else { mem::take(&mut self.pos_watches[var]) };
275275
for i in 0..watches.len() {
276276
if !self.propagate(watches[i], Lit::new(var, self.value(var) == &LBool::True)) {
277-
for j in i..watches.len() {
277+
for &watch in watches.iter().skip(i) {
278278
if self.value(var) == &LBool::True {
279-
self.neg_watches[var].push(watches[j]);
279+
self.neg_watches[var].push(watch);
280280
} else {
281-
self.pos_watches[var].push(watches[j]);
281+
self.pos_watches[var].push(watch);
282282
}
283283
}
284284
self.prop_q.clear();
@@ -339,7 +339,7 @@ impl Engine {
339339
counter += 1;
340340
} else {
341341
// This literal comes from a previous decision level
342-
self.learnt.push(lit.clone());
342+
self.learnt.push(*lit);
343343
}
344344
}
345345
}
@@ -369,8 +369,7 @@ impl Engine {
369369
}
370370

371371
// 5. Final cleanup - undo all assignments made at this level
372-
while !self.propagated_vars.is_empty() {
373-
let var = self.propagated_vars.pop().unwrap();
372+
while let Some(var) = self.propagated_vars.pop() {
374373
self.undo(var);
375374
}
376375
self.undo(self.decision_var);

0 commit comments

Comments
 (0)