@@ -142,13 +142,16 @@ impl IntoLua for LuaScriptValue {
142142 ScriptValue :: Error ( script_error) => return Err ( mlua:: Error :: external ( script_error) ) ,
143143 ScriptValue :: Function ( function) => lua
144144 . create_function ( move |lua, args : Variadic < LuaScriptValue > | {
145- let loc = lua. inspect_stack ( 1 ) . map ( |debug| LocationContext {
146- line : debug. curr_line ( ) . try_into ( ) . unwrap_or_default ( ) ,
147- col : None ,
148- script_name : lua. app_data_ref :: < LuaContextAppData > ( ) . and_then ( |v| {
149- v. last_loaded_script_name . as_ref ( ) . map ( |n| n. to_string ( ) )
150- } ) ,
151- } ) ;
145+ let loc = {
146+ profiling:: scope!( "function call context" ) ;
147+ lua. inspect_stack ( 1 ) . map ( |debug| LocationContext {
148+ line : debug. curr_line ( ) . try_into ( ) . unwrap_or_default ( ) ,
149+ col : None ,
150+ script_name : lua. app_data_ref :: < LuaContextAppData > ( ) . and_then ( |v| {
151+ v. last_loaded_script_name . as_ref ( ) . map ( |n| n. to_string ( ) )
152+ } ) ,
153+ } )
154+ } ;
152155 let out = function
153156 . call (
154157 args. into_iter ( ) . map ( Into :: into) ,
@@ -161,13 +164,16 @@ impl IntoLua for LuaScriptValue {
161164 . into_lua ( lua) ?,
162165 ScriptValue :: FunctionMut ( function) => lua
163166 . create_function ( move |lua, args : Variadic < LuaScriptValue > | {
164- let loc = lua. inspect_stack ( 0 ) . map ( |debug| LocationContext {
165- line : debug. curr_line ( ) as u32 ,
166- col : None ,
167- script_name : lua. app_data_ref :: < LuaContextAppData > ( ) . and_then ( |v| {
168- v. last_loaded_script_name . as_ref ( ) . map ( |n| n. to_string ( ) )
169- } ) ,
170- } ) ;
167+ let loc = {
168+ profiling:: scope!( "function call context" ) ;
169+ lua. inspect_stack ( 1 ) . map ( |debug| LocationContext {
170+ line : debug. curr_line ( ) . try_into ( ) . unwrap_or_default ( ) ,
171+ col : None ,
172+ script_name : lua. app_data_ref :: < LuaContextAppData > ( ) . and_then ( |v| {
173+ v. last_loaded_script_name . as_ref ( ) . map ( |n| n. to_string ( ) )
174+ } ) ,
175+ } )
176+ } ;
171177 let out = function
172178 . call (
173179 args. into_iter ( ) . map ( Into :: into) ,
0 commit comments