From 9abe735061a91422936775a8164953d21c5cc70a Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 2 Jan 2024 14:23:39 +0200 Subject: refactor(tvix/glue): create environment_vars Vec at the end Prevent code in this function from accessing the Vec, realize it only when returning the BuildRequest struct. Change-Id: I385c1adca552c9cb261cd70c5ca3ec45f0d7a9c3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10521 Autosubmit: flokli Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/glue/src/tvix_build.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'tvix/glue/src') diff --git a/tvix/glue/src/tvix_build.rs b/tvix/glue/src/tvix_build.rs index 85a9ba40ac16..399b451c4c71 100644 --- a/tvix/glue/src/tvix_build.rs +++ b/tvix/glue/src/tvix_build.rs @@ -83,13 +83,6 @@ where .map(|(k, v)| (k.clone(), Bytes::from(v.to_vec()))), ); - // Turn this into a sorted-by-key Vec. - let environment_vars = Vec::from_iter( - environment_vars - .into_iter() - .map(|(k, v)| EnvVar { key: k, value: v }), - ); - // Produce inputs. As we refer to the contents here, not just plain store path strings, // we need to perform lookups. // FUTUREWORK: should we also model input_derivations and input_sources with StorePath? @@ -145,7 +138,13 @@ where BuildRequest { command_args, outputs: output_paths, - environment_vars, + + // Turn this into a sorted-by-key Vec. + environment_vars: Vec::from_iter( + environment_vars + .into_iter() + .map(|(key, value)| EnvVar { key, value }), + ), inputs, inputs_dir: nix_compat::store_path::STORE_DIR.into(), constraints, -- cgit 1.4.1