There is no difference in performance.
The scope of the variable is different from the lifetime of the variable. A variable is created on the stack stack for a function, regardless of whether it is declared in the function area or in a code block in the function. The variable exists during the execution of the entire function, only the compiler restricts access to the variable depending on its scope.
(Note that if different rules apply, if the variable is actually part of the closure instead of the usual local variable.)
Guffa source share