Skip to content

Commit

Permalink
Cache information to free the solver
Browse files Browse the repository at this point in the history
  • Loading branch information
maiste authored and tmcgilchrist committed Jul 13, 2022
1 parent 6dd6c87 commit bfd107c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/analyse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,21 @@ module Analysis = struct

let exactly v = Printf.sprintf {|{ = "%s" }|} v

let solver_cache = Hashtbl.create 128

let find_opam_repo_commit_for_ocamlformat ~solve ~platforms version =
let ( let+ ) = Lwt_result.Infix.( >|= ) in
let deps_for_ocamlformat =
( "deps_for_ocamlformat.opam"
, opam_dep_file [("ocamlformat", exactly version)])
in
let+ workers =
solve ~root_pkgs:[deps_for_ocamlformat] ~pinned_pkgs:[] ~platforms
match Hashtbl.find_opt solver_cache platforms with
| Some workers -> Lwt_result.return workers
| None ->
let+ workers = solve ~root_pkgs:[deps_for_ocamlformat] ~pinned_pkgs:[] ~platforms in
Hashtbl.add solver_cache platforms workers;
workers
in
let selection = List.hd workers in
selection.Selection.commit, selection
Expand Down

0 comments on commit bfd107c

Please sign in to comment.