Speed up FnPtr::call when there is a linked scripted function.

This commit is contained in:
Stephen Chung
2022-12-11 16:55:30 +08:00
parent 91f149270a
commit 1f815f995f
6 changed files with 186 additions and 268 deletions

View File

@@ -158,7 +158,10 @@ impl Engine {
if let Some(fn_def) = global.lib.iter().flat_map(|m| m.iter_script_fn()).find_map(
|(_, _, f, _, func)| if f == v.3.as_str() { Some(func) } else { None },
) {
let val: Dynamic = crate::FnPtr::from(fn_def.clone()).into();
let mut fn_ptr =
crate::FnPtr::new_unchecked(v.3.clone(), crate::StaticVec::new_const());
fn_ptr.set_fn_def(Some(fn_def.clone()));
let val: Dynamic = fn_ptr.into();
return Ok(val.into());
}