Skip to content

Commit

Permalink
use peekable on the iterator in conditional clause generation
Browse files Browse the repository at this point in the history
  • Loading branch information
prsabahrami committed Jan 28, 2025
1 parent dbb9843 commit 8cd35a9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/solver/clause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,20 @@ impl Clause {
.expect("no condition candidates");

// Map condition candidates to negative literals and requirement candidates to positive literals
let condition_literal = condition_candidates
let mut iter = condition_candidates
.map(|id| (id, id.negative()))
.chain(requirement_candidates.map(|id| (id, id.positive())))
.find(|&(id, _)| {
.peekable();

let condition_literal = if iter.peek().is_some() {
iter.find(|&(id, _)| {
let value = decision_tracker.assigned_value(id);
value.is_none() || value == Some(true)
})
.map(|(_, literal)| literal);

.map(|(_, literal)| literal)
} else {
None
};
match condition_literal {
// Found a valid literal - use it
Some(literal) => (
Expand Down

0 comments on commit 8cd35a9

Please sign in to comment.