From 151f4437bccd9e826c8fd666ebce9763c4b54a11 Mon Sep 17 00:00:00 2001 From: sterni Date: Mon, 19 Sep 2022 12:08:16 +0200 Subject: refactor(tvix/eval/builtins): avoid unnecessary popping Change-Id: I631b442e19e5c05455d705291c11037eae9ed9e0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6694 Autosubmit: sterni Reviewed-by: grfn Tested-by: BuildkiteCI --- tvix/eval/src/builtins/mod.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'tvix/eval/src') diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index 0268f4f6453c..7e55e8bdbf84 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -55,10 +55,8 @@ fn pure_builtins() -> Vec { let a = args.pop().unwrap(); arithmetic_op!(a, b, +) }), - Builtin::new("abort", &[true], |mut args, _| { - return Err(ErrorKind::Abort( - args.pop().unwrap().to_str()?.as_str().to_owned(), - )); + Builtin::new("abort", &[true], |args, _| { + return Err(ErrorKind::Abort(args[0].to_str()?.to_string())); }), Builtin::new("attrNames", &[true], |args, _| { let xs = args[0].to_attrs()?; @@ -233,10 +231,8 @@ fn pure_builtins() -> Vec { Ok(Value::List(NixList::construct(output.len(), output))) } }), - Builtin::new("throw", &[true], |mut args, _| { - return Err(ErrorKind::Throw( - args.pop().unwrap().to_str()?.as_str().to_owned(), - )); + Builtin::new("throw", &[true], |args, _| { + return Err(ErrorKind::Throw(args[0].to_str()?.to_string())); }), // coerce_to_string forces for us Builtin::new("toString", &[false], |args, vm| { -- cgit 1.4.1