Skip to content

Commit b1dd7ff

Browse files
committed
Merge branch 'topic/improve_resolution' into 'master'
Avoid unnecessary cycles in conflict resolution. Closes #3 See merge request eng/libadalang/adasat!16
2 parents 4a316fe + 66f6607 commit b1dd7ff

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/adasat-dpll.adb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -679,12 +679,19 @@ package body AdaSAT.DPLL is
679679
begin
680680
if Lit_Decisions (Var) = Decision_Level then
681681
Found := Found + 1;
682-
-- TODO: exit if Found > 1?
683-
if Pivot = 0 and then
684-
Lit_Antecedents (Var) /= null
685-
then
686-
Pivot := Var;
687-
Pivot_Index := Lit_Index;
682+
if Pivot = 0 then
683+
if Lit_Antecedents (Var) /= null then
684+
Pivot := Var;
685+
Pivot_Index := Lit_Index;
686+
end if;
687+
elsif Found > 1 then
688+
-- We know there are at least two pivots and we
689+
-- already selected one (since ``Pivot /= 0``), so we
690+
-- can exit early from this internal loop to save some
691+
-- cycles. This is OK because we don't need to know
692+
-- how many potential pivots there were, only that
693+
-- there were more than one.
694+
exit;
688695
end if;
689696
end if;
690697
end;

0 commit comments

Comments
 (0)