From a35dadf9f0c7c98d2ae8761428936a0b9d30489e Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 13 Jan 2023 20:19:48 +0300 Subject: refactor(tvix/derivation): use BTreeSet for derivation outputs When constructing derivations inside builtins.derivationStrict, we'd have to very frequently check whether certain outputs have already been inserted into the derivation inputs. Using a set type is much easier, especially as this has to be ordered and the source data that is being inserted also comes from a set, which might let us pass this more efficiently in the future. Note that the validate function no longer checks the order of the entries, as that is now guaranteed by the type. Change-Id: I2fbb984facba3e668075f6f8df8992092368c63d Reviewed-on: https://cl.tvl.fyi/c/depot/+/7826 Tested-by: BuildkiteCI Reviewed-by: flokli --- tvix/derivation/src/tests/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tvix/derivation/src/tests/mod.rs') diff --git a/tvix/derivation/src/tests/mod.rs b/tvix/derivation/src/tests/mod.rs index cb98a27cdf..bd5d9f34cb 100644 --- a/tvix/derivation/src/tests/mod.rs +++ b/tvix/derivation/src/tests/mod.rs @@ -1,5 +1,6 @@ use crate::derivation::Derivation; use crate::output::{Hash, Output}; +use std::collections::BTreeSet; use std::fs::File; use std::io::Read; use std::path::Path; @@ -272,9 +273,10 @@ fn output_path_construction() { ); // assemble foo input_derivations - foo_drv - .input_derivations - .insert(bar_drv_path.to_absolute_path(), vec!["out".to_string()]); + foo_drv.input_derivations.insert( + bar_drv_path.to_absolute_path(), + BTreeSet::from(["out".to_string()]), + ); // calculate foo output paths let foo_calc_result = foo_drv.calculate_output_paths( -- cgit 1.4.1