Avoid copying arguments for function calls.

This commit is contained in:
Stephen Chung
2020-05-03 16:54:24 +08:00
parent fc66a7ecef
commit d83b829810
8 changed files with 81 additions and 64 deletions

View File

@@ -692,7 +692,7 @@ impl Engine {
&self,
fn_lib: &FunctionsLib,
fn_name: &str,
args: &mut [&mut Dynamic],
args: &mut FnCallArgs,
def_val: Option<&Dynamic>,
pos: Position,
level: usize,
@@ -1227,7 +1227,7 @@ impl Engine {
#[cfg(not(feature = "no_index"))]
Expr::Array(contents, _) => Ok(Dynamic(Union::Array(Box::new(
contents
.into_iter()
.iter()
.map(|item| self.eval_expr(scope, state, fn_lib, item, level))
.collect::<Result<Vec<_>, _>>()?,
)))),
@@ -1235,9 +1235,9 @@ impl Engine {
#[cfg(not(feature = "no_object"))]
Expr::Map(contents, _) => Ok(Dynamic(Union::Map(Box::new(
contents
.into_iter()
.iter()
.map(|(key, expr, _)| {
self.eval_expr(scope, state, fn_lib, &expr, level)
self.eval_expr(scope, state, fn_lib, expr, level)
.map(|val| (key.clone(), val))
})
.collect::<Result<HashMap<_, _>, _>>()?,