@@ -42,6 +42,7 @@ module VarID : sig
42
42
val create : unit -> t
43
43
val mem : t -> id -> bool
44
44
val add : t -> id -> unit
45
+ val clear : t -> unit
45
46
end
46
47
end = struct
47
48
type t = int
@@ -153,6 +154,12 @@ module Make (User : USER) = struct
153
154
}
154
155
155
156
let create () = { pos = VarID.Hash_set. create () ; neg = VarID.Hash_set. create () }
157
+ let temp = create ()
158
+
159
+ let clear () =
160
+ VarID.Hash_set. clear temp.pos;
161
+ VarID.Hash_set. clear temp.neg
162
+ ;;
156
163
157
164
let mem { pos; neg } (sign , lit ) =
158
165
match sign with
@@ -194,7 +201,8 @@ module Make (User : USER) = struct
194
201
;;
195
202
196
203
let remove_duplicates lits =
197
- let seen = LitSet. create () in
204
+ LitSet. clear () ;
205
+ let seen = LitSet. temp in
198
206
let rec find_unique = function
199
207
| [] -> []
200
208
| x :: xs when LitSet. mem seen x -> find_unique xs
@@ -454,13 +462,13 @@ module Make (User : USER) = struct
454
462
enqueue problem lits.(0 ) (Clause t))
455
463
else (
456
464
match lit_value lits.(i) with
465
+ | False -> find_not_false (i + 1 )
457
466
| Undecided | True ->
458
467
(* If it's True then we've already done our job,
459
468
so this means we don't get notified unless we backtrack, which is fine. *)
460
469
Array. swap lits 1 i;
461
470
watch_lit (neg lits.(1 )) t;
462
- true
463
- | False -> find_not_false (i + 1 ))
471
+ true )
464
472
in
465
473
find_not_false 2 )
466
474
| At_most_one (current , problem , lits ) ->
@@ -595,7 +603,10 @@ module Make (User : USER) = struct
595
603
then (* Trivially true already if any literal is True. *)
596
604
()
597
605
else (
598
- let seen = LitSet. create () in
606
+ let seen =
607
+ LitSet. clear () ;
608
+ LitSet. temp
609
+ in
599
610
let rec simplify unique = function
600
611
| [] -> Some unique
601
612
| x :: _ when LitSet. mem seen (neg x) -> None (* X or not(X) is always True *)
0 commit comments