Skip to content

Commit e7088e3

Browse files
committed
Use non-monotonic function within filter
1 parent c1d1a07 commit e7088e3

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/cdomain/value/cdomains/intDomain0.ml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -560,17 +560,19 @@ module IntervalArith (Ints_t : IntOps.IntOps) = struct
560560
ResettableLazy.force ts
561561

562562
let upper_threshold u max_ik =
563-
let ts = find_thresholds WideningThresholds.upper_thresholds in
564563
let u = Ints_t.to_bigint u in
565564
let max_ik' = Ints_t.to_bigint max_ik in
566-
let t = WideningThresholds.Thresholds.find_first_opt (fun x -> Z.compare u x <= 0 && Z.compare x max_ik' <= 0) ts in
567-
BatOption.map_default Ints_t.of_bigint max_ik t
565+
find_thresholds WideningThresholds.upper_thresholds
566+
|> WideningThresholds.Thresholds.find_first_opt (fun x -> Z.compare u x <= 0)
567+
|> BatOption.filter (fun x -> Z.compare x max_ik' <= 0)
568+
|> BatOption.map_default Ints_t.of_bigint max_ik
568569
let lower_threshold l min_ik =
569-
let ts = find_thresholds WideningThresholds.lower_thresholds in
570570
let l = Ints_t.to_bigint l in
571571
let min_ik' = Ints_t.to_bigint min_ik in
572-
let t = WideningThresholds.Thresholds.find_last_opt (fun x -> Z.compare l x >= 0 && Z.compare x min_ik' >= 0) ts in
573-
BatOption.map_default Ints_t.of_bigint min_ik t
572+
find_thresholds WideningThresholds.lower_thresholds
573+
|> WideningThresholds.Thresholds.find_last_opt (fun x -> Z.compare l x >= 0)
574+
|> BatOption.filter (fun x -> Z.compare x min_ik' >= 0)
575+
|> BatOption.map_default Ints_t.of_bigint min_ik
574576

575577
let is_threshold t ts =
576578
let ts = find_thresholds ts in

0 commit comments

Comments
 (0)