From a541a4507ffac6960d28a1dc2e4aa7171cfcef1d Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Fri, 27 Mar 2020 16:46:19 +0800 Subject: [PATCH] Remove internal function. --- src/api.rs | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/api.rs b/src/api.rs index dd006161..db92aed7 100644 --- a/src/api.rs +++ b/src/api.rs @@ -880,24 +880,18 @@ impl<'e> Engine<'e> { name: &str, args: A, ) -> Result { - // Split out non-generic portion to avoid exploding code size - fn call_fn_internal( - engine: &mut Engine, - name: &str, - mut values: Vec, - ) -> Result { - let mut values: Vec<_> = values.iter_mut().map(Dynamic::as_mut).collect(); - engine.call_fn_raw(name, &mut values, None, Position::none(), 0) - } + let mut values = args.into_vec(); + let mut arg_values: Vec<_> = values.iter_mut().map(Dynamic::as_mut).collect(); - call_fn_internal(self, name, args.into_vec()).and_then(|b| { - b.downcast().map(|b| *b).map_err(|a| { - EvalAltResult::ErrorMismatchOutputType( - self.map_type_name((*a).type_name()).into(), - Position::none(), - ) + self.call_fn_raw(name, &mut arg_values, None, Position::none(), 0) + .and_then(|b| { + b.downcast().map(|b| *b).map_err(|a| { + EvalAltResult::ErrorMismatchOutputType( + self.map_type_name((*a).type_name()).into(), + Position::none(), + ) + }) }) - }) } /// Optimize the `AST` with constants defined in an external Scope.