diff --git a/src/api/call_fn.rs b/src/api/call_fn.rs index 1f2ec085..dcbfbf99 100644 --- a/src/api/call_fn.rs +++ b/src/api/call_fn.rs @@ -162,7 +162,7 @@ impl Engine { ) -> RhaiResult { let mut arg_values = arg_values; - self.call_fn_internal( + self._call_fn( scope, &mut GlobalRuntimeState::new(self), &mut Caches::new(), @@ -215,7 +215,7 @@ impl Engine { this_ptr: Option<&mut Dynamic>, arg_values: &mut [Dynamic], ) -> RhaiResult { - self.call_fn_internal( + self._call_fn( scope, global, caches, @@ -228,7 +228,7 @@ impl Engine { ) } /// Call a script function defined in an [`AST`] with multiple [`Dynamic`] arguments. - fn call_fn_internal( + fn _call_fn( &self, scope: &mut Scope, global: &mut GlobalRuntimeState, diff --git a/src/ast/ast.rs b/src/ast/ast.rs index 0b9ec418..108b204e 100644 --- a/src/ast/ast.rs +++ b/src/ast/ast.rs @@ -809,30 +809,21 @@ impl AST { /// Return `false` from the callback to terminate the walk. #[cfg(not(feature = "internals"))] #[cfg(not(feature = "no_module"))] - #[inline] + #[inline(always)] pub(crate) fn walk(&self, on_node: &mut impl FnMut(&[ASTNode]) -> bool) -> bool { - let path = &mut Vec::new(); - - for stmt in self.statements() { - if !stmt.walk(path, on_node) { - return false; - } - } - #[cfg(not(feature = "no_function"))] - for stmt in self.iter_fn_def().flat_map(|f| f.body.iter()) { - if !stmt.walk(path, on_node) { - return false; - } - } - - true + self.walk_raw(on_node) } /// _(internals)_ Recursively walk the [`AST`], including function bodies (if any). /// Return `false` from the callback to terminate the walk. /// Exported under the `internals` feature only. #[cfg(feature = "internals")] - #[inline] + #[inline(always)] pub fn walk(&self, on_node: &mut impl FnMut(&[ASTNode]) -> bool) -> bool { + self._walk(on_node) + } + /// Recursively walk the [`AST`], including function bodies (if any). + /// Return `false` from the callback to terminate the walk. + fn _walk(&self, on_node: &mut impl FnMut(&[ASTNode]) -> bool) -> bool { let path = &mut Vec::new(); for stmt in self.statements() { diff --git a/src/parser.rs b/src/parser.rs index d689ce83..0feeaf19 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -57,7 +57,7 @@ pub struct ParseState<'e> { pub block_stack_len: usize, /// Tracks a list of external variables (variables that are not explicitly declared in the scope). #[cfg(not(feature = "no_closure"))] - pub external_vars: Vec, + pub external_vars: crate::FnArgsVec, /// An indicator that disables variable capturing into externals one single time /// up until the nearest consumed Identifier token. /// If set to false the next call to [`access_var`][ParseState::access_var] will not capture the variable. @@ -80,7 +80,7 @@ impl<'e> ParseState<'e> { Self { tokenizer_control, #[cfg(not(feature = "no_closure"))] - external_vars: Vec::new(), + external_vars: crate::FnArgsVec::new_const(), #[cfg(not(feature = "no_closure"))] allow_capture: true, interned_strings: StringsInterner::new(),