From 7e286aab1a573edc9aef16bb68e9907371917adc Mon Sep 17 00:00:00 2001 From: Aspen Smith Date: Sat, 10 Feb 2024 12:39:24 -0500 Subject: feat(tvix/eval): Box Value::Catchable This is now the only enum variant for Value that is larger than 8 bytes (it's 16 bytes), so boxing it (especially since it's not perf-critical) allows us to get the Value size down to only 16 bytes! Change-Id: I98598e2b762944448bef982e8ff7da6d6683c4aa Reviewed-on: https://cl.tvl.fyi/c/depot/+/10798 Tested-by: BuildkiteCI Reviewed-by: raitobezarius Autosubmit: aspen --- tvix/glue/src/builtins/derivation.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tvix/glue') diff --git a/tvix/glue/src/builtins/derivation.rs b/tvix/glue/src/builtins/derivation.rs index 299d064c40d6..efcacd8310cd 100644 --- a/tvix/glue/src/builtins/derivation.rs +++ b/tvix/glue/src/builtins/derivation.rs @@ -248,7 +248,7 @@ pub(crate) mod derivation_builtins { "args" => { for arg in value.to_list()? { match strong_importing_coerce_to_string(&co, arg).await { - Err(cek) => return Ok(Value::Catchable(cek)), + Err(cek) => return Ok(Value::from(cek)), Ok(s) => { input_context.mimic(&s); drv.arguments.push(s.to_str()?.to_owned()) @@ -299,7 +299,7 @@ pub(crate) mod derivation_builtins { // handle builder and system. "builder" | "system" => { match strong_importing_coerce_to_string(&co, value).await { - Err(cek) => return Ok(Value::Catchable(cek)), + Err(cek) => return Ok(Value::from(cek)), Ok(val_str) => { input_context.mimic(&val_str); @@ -334,7 +334,7 @@ pub(crate) mod derivation_builtins { // In non-SA case, coerce to string and add to env. if let Some(ref mut structured_attrs) = structured_attrs { let val = generators::request_force(&co, value).await; - if matches!(val, Value::Catchable(_)) { + if val.is_catchable() { return Ok(val); } @@ -343,14 +343,14 @@ pub(crate) mod derivation_builtins { let val_json = match val.into_json(&co).await? { Ok(v) => v, - Err(cek) => return Ok(Value::Catchable(cek)), + Err(cek) => return Ok(Value::from(cek)), }; // No need to check for dups, we only iterate over every attribute name once structured_attrs.insert(arg_name.to_owned(), val_json); } else { match strong_importing_coerce_to_string(&co, value).await { - Err(cek) => return Ok(Value::Catchable(cek)), + Err(cek) => return Ok(Value::from(cek)), Ok(val_str) => { input_context.mimic(&val_str); @@ -384,21 +384,21 @@ pub(crate) mod derivation_builtins { .await .context("evaluating the `outputHash` parameter")? { - Err(cek) => return Ok(Value::Catchable(cek)), + Err(cek) => return Ok(Value::from(cek)), Ok(s) => s, }; let output_hash_algo = match select_string(&co, &input, "outputHashAlgo") .await .context("evaluating the `outputHashAlgo` parameter")? { - Err(cek) => return Ok(Value::Catchable(cek)), + Err(cek) => return Ok(Value::from(cek)), Ok(s) => s, }; let output_hash_mode = match select_string(&co, &input, "outputHashMode") .await .context("evaluating the `outputHashMode` parameter")? { - Err(cek) => return Ok(Value::Catchable(cek)), + Err(cek) => return Ok(Value::from(cek)), Ok(s) => s, }; -- cgit 1.4.1