Skip to content

Commit

Permalink
avoid List.find_map
Browse files Browse the repository at this point in the history
  • Loading branch information
stilscher committed Jun 21, 2023
1 parent 99da0cb commit 8ac975c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/ext/syntacticsearch/funcVar.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ let rec delete_duplicates list tbl =
| [] -> []

let map_gfun f = function GFun (dec, loc) -> f dec loc | _ -> None
let filter_gfun c = function GFun (dec, loc) when c dec loc -> true | _ -> false

let map_gvar f = function
| GVar (varinfo, initinfo, loc) -> f varinfo initinfo loc
Expand All @@ -28,9 +29,10 @@ let map_gvar f = function
let is_temporary id = Inthash.mem allTempVars id

let get_func_loc cilfile fname =
List.find_map
(map_gfun (fun dec loc -> if dec.svar.vname = fname then Some loc else None))
cilfile.globals
try
let g = List.find (filter_gfun (fun dec loc -> dec.svar.vname = fname)) cilfile.globals in
map_gfun (fun dec loc -> Some loc) g
with Not_found -> None

let generate_globalvar_list cilfile =
Util.list_filter_map
Expand Down

0 comments on commit 8ac975c

Please sign in to comment.