Skip to content

Commit

Permalink
replace a collect<Result> call by direct loop.
Browse files Browse the repository at this point in the history
See rust-lang/rust#48994 for rationale.
  • Loading branch information
kennytm committed Jan 25, 2020
1 parent 4c3b967 commit fe590fa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use crate::{
error::Error,
functions::Function,
functions::{Arguments, Function},
parser::{Expr, QName},
value::Value,
};
Expand Down Expand Up @@ -271,8 +271,11 @@ impl Compiled {
C::SubRowNum => state.sub_row_num.into(),
C::Constant(v) => v.clone(),
C::RawFunction { function, args } => {
let args = args.iter().map(|c| c.eval(state)).collect::<Result<_, _>>()?;
let compiled = (*function).compile(&state.compile_context, args)?;
let mut eval_args = Arguments::with_capacity(args.len());
for c in args {
eval_args.push(c.eval(state)?);
}
let compiled = (*function).compile(&state.compile_context, eval_args)?;
compiled.eval(state)?
}
C::GetVariable(index) => state.compile_context.variables[*index].clone(),
Expand Down

0 comments on commit fe590fa

Please sign in to comment.