Skip to content

Commit 3bd3e26

Browse files
authored
Parse global env only once (#12764)
* refactor(pkg): stop re-parsing the global env doing it once is plenty Signed-off-by: Rudi Grinberg <[email protected]>
1 parent c7c1170 commit 3bd3e26

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/dune_rules/pkg_rules.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,11 @@ module Value_list_env = struct
331331
string (in the style of the PATH variable). *)
332332
type t = Value.t list Env.Map.t
333333

334-
let parse_strings s = Bin.parse s |> List.map ~f:(fun s -> Value.String s)
335-
let of_env env : t = Env.to_map env |> Env.Map.map ~f:parse_strings
334+
let global : t Lazy.t =
335+
let parse_strings s = Bin.parse s |> List.map ~f:(fun s -> Value.String s) in
336+
let of_env env : t = Env.to_map env |> Env.Map.map ~f:parse_strings in
337+
lazy (of_env (Global.env ()))
338+
;;
336339

337340
(* Concatenate a list of values in the style of lists found in
338341
environment variables, such as PATH *)
@@ -575,7 +578,7 @@ module Pkg = struct
575578
for build actions to run successfully, such as $PATH on systems where the
576579
shell's default $PATH variable doesn't include the location of standard
577580
programs or build tools (e.g. NixOS). *)
578-
Value_list_env.extend_concat_path (Value_list_env.of_env (Global.env ())) package_env
581+
Value_list_env.extend_concat_path (Lazy.force Value_list_env.global) package_env
579582
;;
580583

581584
let exported_env t = Value_list_env.to_env @@ exported_value_env t

0 commit comments

Comments
 (0)