Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions engine/src/ast/function_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,11 @@ impl ValueExpr for FunctionCallExpr {
.any(FunctionCallArgExpr::is_expensive_to_reevaluate);
let mut args = args
.into_iter()
.map(|arg| compiler.compile_function_call_arg_expr(arg))
.collect::<Vec<_>>();
.map(|arg| compiler.compile_function_call_arg_expr(arg));

if map_each_count > 0 {
let first = args.remove(0);
let args = args.into_boxed_slice();
let first = args.next().unwrap();
let args = args.collect::<Box<[_]>>();

#[inline(always)]
fn compute<'a, I: ExactSizeIterator<Item = CompiledValueResult<'a>>>(
Expand Down Expand Up @@ -356,7 +355,10 @@ impl ValueExpr for FunctionCallExpr {
// re-evaluate, so evaluate all of them once per call and
// reuse them (cheaply cloned) for every element instead of
// re-executing the argument expressions for every element.
let extra_args = args.iter().map(|arg| arg.execute(ctx)).collect::<Vec<_>>();
let extra_args = args
.iter()
.map(|arg| arg.execute(ctx))
.collect::<Box<[_]>>();
compute(
first.execute(ctx),
&call,
Expand All @@ -382,7 +384,7 @@ impl ValueExpr for FunctionCallExpr {
})
}
} else {
let args = args.into_boxed_slice();
let args = args.collect::<Box<[_]>>();
CompiledValueExpr::new(move |ctx| {
match call(&mut args.iter().map(|arg| arg.execute(ctx))) {
Some(value) => {
Expand Down
6 changes: 2 additions & 4 deletions engine/src/ast/logical_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,7 @@ impl Expr for LogicalExpr {
CompiledExpr::One(one) => one,
CompiledExpr::Vec(_) => unreachable!(),
})
.collect::<Vec<_>>()
.into_boxed_slice();
.collect::<Box<[_]>>();
match op {
LogicalOp::And => CompiledExpr::One(CompiledOneExpr::new(move |ctx| {
first.execute(ctx) && items.iter().all(|item| item.execute(ctx))
Expand All @@ -434,8 +433,7 @@ impl Expr for LogicalExpr {
CompiledExpr::One(_) => unreachable!(),
CompiledExpr::Vec(vec) => vec,
})
.collect::<Vec<_>>()
.into_boxed_slice();
.collect::<Box<[_]>>();
match op {
LogicalOp::And => CompiledExpr::Vec(CompiledVecExpr::new(move |ctx| {
let items = items.iter().map(|item| item.execute(ctx));
Expand Down
Loading