Skip to content

Commit 1083c23

Browse files
Merge pull request #975 from adelavais/Seq-optimization-clean
Seq-optimization clean version
2 parents 22a720c + 6aef108 commit 1083c23

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/analyses/base.ml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ struct
107107
| (info,value)::xs ->
108108
match value with
109109
| `Address t when hasAttribute "goblint_array_domain" info.vattr ->
110-
let possibleVars = PreValueDomain.AD.to_var_may t in
111-
List.fold_left (fun map arr -> VarMap.add arr (info.vattr) map) (pointedArrayMap xs) @@ List.filter (fun info -> isArrayType info.vtype) possibleVars
110+
let possibleVars = List.to_seq (PreValueDomain.AD.to_var_may t) in
111+
Seq.fold_left (fun map arr -> VarMap.add arr (info.vattr) map) (pointedArrayMap xs) @@ Seq.filter (fun info -> isArrayType info.vtype) possibleVars
112112
| _ -> pointedArrayMap xs
113113
in
114114
match VarH.find_option !array_map fundec.svar with
@@ -1251,13 +1251,13 @@ struct
12511251
| Q.EvalLength e -> begin
12521252
match eval_rv_address (Analyses.ask_of_ctx ctx) ctx.global ctx.local e with
12531253
| `Address a ->
1254-
let slen = List.map String.length (AD.to_string a) in
1254+
let slen = Seq.map String.length (List.to_seq (AD.to_string a)) in
12551255
let lenOf = function
12561256
| TArray (_, l, _) -> (try Some (lenOfArray l) with LenOfArray -> None)
12571257
| _ -> None
12581258
in
1259-
let alen = List.filter_map (fun v -> lenOf v.vtype) (AD.to_var_may a) in
1260-
let d = List.fold_left ID.join (ID.bot_of (Cilfacade.ptrdiff_ikind ())) (List.map (ID.of_int (Cilfacade.ptrdiff_ikind ()) %BI.of_int) (slen @ alen)) in
1259+
let alen = Seq.filter_map (fun v -> lenOf v.vtype) (List.to_seq (AD.to_var_may a)) in
1260+
let d = Seq.fold_left ID.join (ID.bot_of (Cilfacade.ptrdiff_ikind ())) (Seq.map (ID.of_int (Cilfacade.ptrdiff_ikind ()) %BI.of_int) (Seq.append slen alen)) in
12611261
(* ignore @@ printf "EvalLength %a = %a\n" d_exp e ID.pretty d; *)
12621262
`Lifted d
12631263
| `Bot -> Queries.Result.bot q (* TODO: remove *)
@@ -1680,8 +1680,8 @@ struct
16801680
| None -> xs
16811681
in
16821682
let vars = AD.fold find_fps adrs [] in (* filter_map from AD to list *)
1683-
let funs = List.filter (fun x -> isFunctionType x.vtype) vars in
1684-
List.iter (fun x -> ctx.spawn None x []) funs
1683+
let funs = Seq.filter (fun x -> isFunctionType x.vtype)@@ List.to_seq vars in
1684+
Seq.iter (fun x -> ctx.spawn None x []) funs
16851685
| _ -> ()
16861686
);
16871687
match lval with (* this section ensure global variables contain bottom values of the proper type before setting them *)
@@ -2234,12 +2234,13 @@ struct
22342234
let st = invalidate_ret_lv st in
22352235
(* apply all registered abstract effects from other analysis on the base value domain *)
22362236
LibraryFunctionEffects.effects_for f.vname args
2237-
|> List.map (fun sets ->
2238-
List.fold_left (fun acc (lv, x) ->
2237+
|> List.to_seq
2238+
|> Seq.map (fun sets ->
2239+
BatList.fold_left (fun acc (lv, x) ->
22392240
set ~ctx (Analyses.ask_of_ctx ctx) ctx.global acc (eval_lv (Analyses.ask_of_ctx ctx) ctx.global acc lv) (Cilfacade.typeOfLval lv) x
22402241
) st sets
22412242
)
2242-
|> BatList.fold_left D.meet st
2243+
|> Seq.fold_left D.meet st
22432244

22442245
(* List.map (fun f -> f (fun lv -> (fun x -> set ~ctx:(Some ctx) ctx.ask ctx.global st (eval_lv ctx.ask ctx.global st lv) (Cilfacade.typeOfLval lv) x))) (LF.effects_for f.vname args) |> BatList.fold_left D.meet st *)
22452246
end

0 commit comments

Comments
 (0)