diff --git a/CHANGELOG.md b/CHANGELOG.md index c7f85b83..9a297a01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ Enhancements * `to_json` is added to object maps to cheaply convert it to JSON format (`()` is mapped to `null`, all other data types must be supported by JSON) * A global function `format_map_as_json` is provided which is the same as `to_json` for object maps. * `FileModuleResolver` now accepts a custom `Scope` to provide constants for optimization. -* A new low-level method `Engine::call_fn_with_global_raw` is added to add speed to repeated function calls. +* A new low-level method `Engine::call_fn_raw_raw` is added to add speed to repeated function calls. Version 1.6.1 diff --git a/src/api/call_fn.rs b/src/api/call_fn.rs index 838cad07..9d327c80 100644 --- a/src/api/call_fn.rs +++ b/src/api/call_fn.rs @@ -163,6 +163,7 @@ impl Engine { self.call_fn_internal( scope, &mut GlobalRuntimeState::new(self), + &mut Caches::new(), ast, eval_ast, rewind_scope, @@ -186,9 +187,9 @@ impl Engine { /// /// This function is very low level. /// - /// A [`GlobalRuntimeState`] needs to be passed into the function, which can be created via - /// [`GlobalRuntimeState::new`]. This makes repeatedly calling particular functions - /// extremely efficient as the functions resolution cache inside the [`GlobalRuntimeState`] + /// A [`GlobalRuntimeState`] and [`Caches`] need to be passed into the function, which can be + /// created via [`GlobalRuntimeState::new`] and [`Caches::new`]. + /// This makes repeatedly calling particular functions more efficient as the functions resolution cache /// is kept intact. /// /// # Arguments @@ -200,10 +201,11 @@ impl Engine { /// calling this function. #[cfg(feature = "internals")] #[inline(always)] - pub fn call_fn_with_global_raw( + pub fn call_fn_raw_raw( &self, scope: &mut Scope, global: &mut GlobalRuntimeState, + caches: &mut Caches, ast: &AST, eval_ast: bool, rewind_scope: bool, @@ -214,6 +216,7 @@ impl Engine { self.call_fn_internal( scope, global, + caches, ast, eval_ast, rewind_scope, @@ -228,6 +231,7 @@ impl Engine { &self, scope: &mut Scope, global: &mut GlobalRuntimeState, + caches: &mut Caches, ast: &AST, eval_ast: bool, rewind_scope: bool, @@ -235,8 +239,6 @@ impl Engine { this_ptr: Option<&mut Dynamic>, arg_values: impl AsMut<[Dynamic]>, ) -> RhaiResult { - let caches = &mut Caches::new(); - let statements = ast.statements(); let orig_scope_len = scope.len();